Gcc Error Extra Semicolon
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up “Extra ';' ” compile error in Xcode C++ project up vote 1 down vote favorite I've got a C++ Xcode 3 project generated from CMake scripts. It uses some open-source headers which have always worked before but in this project I get a compile error Extra ';' when trailing brackets have an uneccessary semi-colon: if(...) { ... }; Is there some compiler option which makes trailing semi-colons an error, which I can turn off? Here is one of the offending files, see line 259: http://zziplib.svn.sourceforge.net/viewvc/zziplib/trunk/zzip-0/zzip/zzip.h?revision=523&view=markup c++ xcode gcc xcode3.2 share|improve this question edited Sep 12 '12 at 9:18 asked Sep 12 '12 at 8:41 Mr. Boy 16.8k50180379 A semicolon following the closing } of an if statement should be perfectly legal. In that context, it's simply a null statement. You mention headers, so I suspect you actually have a stray semicolon after a declaration. Please show us an actual code snippet. Can you tell us what open source header you're using? Can you just fix the header? –Keith Thompson Sep 12 '12 at 8:58 @KeithThompson, added a link to the real file. –Mr. Boy Sep 12 '12 at 9:19 add a comment| 2 Answers 2 active oldest votes up vote 4 down vote accepted The semicolon warning come courtesy of the -pedantic (or -pedantic-errors) option; I don't think you can disable it separately. I'd recommend removing the semicolon rather than the war
warnings Date: Wed, 29 Jun 2005 09:27:29 +0200 User-agent: Mozilla Thunderbird 1.0.2 (Windows/20050317) Dave Steffen wrote: Hi Folks, If you turn GCC 3.4's warnings up high enough, you'll get warnings about extra semicolons from such things as int foo() { // ... code in here } ; That semicolon at the end isn't necessary, of course, but I don't think it hurts anything being there. We tend to end up with such things as the result of macro expansion, particularly http://stackoverflow.com/questions/12384280/extra-compile-error-in-xcode-c-project when using Boost's preprocessor metaprogramming stuff. I like all the other stuff I get with -Wextra -Wall... is there a compiler switch to turn off the "extra `;' " warnings? Alternately, can anyone suggest a legal construct that could be placed between the } and ; (again, say, in a macro definition) to https://lists.gnu.org/archive/html/help-gplusplus/2005-06/msg00061.html silence the warning? Note: The superfluous semicolon often brings you in trouble with function-like macros and if--else. The comp.lang.c and comp.lang.c++ faqs both provide a standard way to define function-like macros (different, AFAIR), so I recommend having a look at them. comp.lang.c's faq answer ist #define foo(bar) do { \ /* STUFF ..... */ \ } while (0) Note that the semicolon comes in by the user using the macro like a function: if (qux) foo(baz); else ..... Cheers Michael -- E-Mail: Mine is an /at/ gmx /dot/ de address. reply via email to [Prev in Thread] Current Thread [Next in Thread] GCC 3.4.3, silencing "extra semicolon" warnings, Dave Steffen, 2005/06/28 Re: GCC 3.4.3, silencing "extra semicolon" warnings, Michael Mair<= Prev by Date: GCC 3.4.3, silencing "extra semicolon" warnings Next by Date: Passing names of libraries to linker. Previous by thread: GCC 3.4.3, silencing "extra semicolon" warnings Next by thread: Passing names of libraries to linker. Index(es): Date Thread
C Lines 21 MD5 Hash 723a8cffe723996920f72e98e4a05e5a Estimated Cost $283 (why?) Repository https://searchcode.com/codesearch/view/12715438/ http://android-gcc-objc2-0.googlecode.com/svn/trunk/ View Raw File Find Similar Files View File Tree 1 2 3 4 5 6 7 8 9 https://books.google.com/books?id=78dO3P_QjPgC&pg=PA202&lpg=PA202&dq=gcc+error+extra+semicolon&source=bl&ots=I0qJfA5VxD&sig=d1L6_Tz2smMGouZhXAgyQcboFJM&hl=en&sa=X&ved=0ahUKEwj4_ZKTztjPAhUEdh4KHfmUB8kQ6AEIVDAJ 10 11 12 13 14 15 16 17 18 19 20/* Test diagnostics for missing and extra semicolons in structures. gcc error Test with -pedantic-errors. */ /* Origin: Joseph Myers
from GoogleSign inHidden fieldsBooksbooks.google.comhttps://books.google.com/books/about/DAT10603_Programming_Principle.html?id=78dO3P_QjPgC&utm_source=gb-gplus-shareDAT10603 Programming PrincipleMy libraryHelpAdvanced Book SearchGet print bookNo eBook availablePediaPressAll sellers»Get Textbooks on Google PlayRent and save from the world's largest eBookstore. Read, highlight, and take notes, across web, tablet, and phone.Go to Google Play Now »DAT10603 Programming PrinciplePediaPress 0 Reviewshttps://books.google.com/books/about/DAT10603_Programming_Principle.html?id=78dO3P_QjPgC Preview this book » What people are saying-Write a reviewWe haven't found any reviews in the usual places.Selected pagesTitle PageTable of ContentsIndexContentsArticles 1 Problem Solving 81 Algorithm 93 Basic Programming Structure 127 Data Input Output 215 Control Statement 245 Functions 251 Appendix 267 Article Licenses 285 Common terms and phrasesalgorithms Alike 3.0 Unported allocation anonymous edits arguments array assembly language assignment Attribution-Share Alike 3.0 binary Bjarne Bjarne Stroustrup bytes calculation call stack char character close="none">T T::operator Commons Attribution-Share Alike compiler Complex problem solving Creative Commons Attribution-Share declared define document electronic engineering ENIAC evaluated example execution expression flowcharts functional programming Hillsdale implementation input instructions integer Intel ISBN ISO/IEC Lawrence Erlbaum Associates License logic long int machine macro malloc mathematical mechanical memory multiple object object-oriented operator P. A. Frensch paradigm parameters phase pointer preprocessor printf procedural programming procedure processor programming language pseudocode punched cards recursive requirements Retrieved return value RISC run-time SDLC sequence software development specified stack standard library statement stdio.h storage string Stroustrup struct structure subprogram subroutine syntax syntaxhighlight lang="cpp T::operator const T& templates tion Turing undefined behavior unsigned variable VLIW waterfall model Yes YesBibliographic informationTitleDAT10603 Programming PrinciplePublisherPediaPress  Export CitationBiBTeXEndNoteRefManAbout Google Book