Eclipse Cdt Macro Syntax Error
Contents |
Things LocationTech Long-Term Support PolarSys Science OpenMDM More Community Marketplace Events Planet Eclipse Newsletter Videos Participate Report a Bug Forums Mailing Lists Wiki IRC How to Contribute Working Groups eclipse disable syntax error Automotive Internet of Things LocationTech Long-Term Support PolarSys Science OpenMDM Toggle navigation
Eclipse Packed Syntax Error
Home Projects Forums Eclipse Community Forums Forum Search: Search Help Register Login Home Home» eclipse symbol could not be resolved Language IDEs» C / C++ IDE (CDT)» syntax error for preprocessor macro, even after defining symbol(Can't stop some preprocessor macros from showing up as syntax errors) Show: Today's Messages :: Show eclipse c++11 Polls :: Message Navigator syntax error for preprocessor macro, even after defining symbol [message #631544] Thu, 07 October 2010 21:53 LaurenVMessages: 1Registered: October 2010 Junior Member I have a define for my ARM cross compile toolchain that is: #define PACKED __packed I then define a struct as follows: typedef PACKED struct { char x; int y; }MY_STRUCT; This definition comes up highlighted as a syntax error(fixed if I remove the PACKED keyword). and It doesn't index the structure. I have tried adding an empty symbol in "Paths and Symbols" for PACKED and __packed for all languages and re-indexed. This did not solve the problem. Thanks for your time. Report message to a moderator Re: syntax error for preprocessor macro, even after defining symbol [message #790204 is a reply to message #631544] Fri, 03 February 2012 23:51 Vynce -Messages: 6Registered: January 2012 Junior Member I realize that this is an old thread, but I'm running into exactly the same issue on an embedded ARM project. It's possible to work around the issue with some preprocessor magic, but it would be nice if there was some way to just tell Eclipse/CDT to ignore the __packed keyword somehow. We've got __packed keywords scattered all over the place and it would be quite an undertaking to replace all of them just to make Eclipse index the structures. Any ideas? // Define NO_PACKED_SUPPORT in Eclipse and leave // it undefined for hardware build
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 Why does Eclipse CDT say: 'syntax error', but compilation no problem up vote 11 down vote favorite 4 I am working in existing C code which https://www.eclipse.org/forums/index.php/t/198067/ has a couple of lines with statements similar to this one: struct collect_conn *tc = (struct collect_conn *) ((char *)c - offsetof(struct collect_conn, runicast_conn)); The struct collect_conn goes along the following lines: struct collect_conn { struct runicast_conn runicast_conn; struct announcement announcement; const struct collect_callbacks *cb; struct ctimer t; uint16_t rtmetric; uint8_t forwarding; uint8_t seqno; }; I am using Eclipse CDT, and it marks the line with an orange squiggly line as 'syntax error'. I think it http://stackoverflow.com/questions/802410/why-does-eclipse-cdt-say-syntax-error-but-compilation-no-problem is marked as such by the CDT indexer. However, compilation (manually in a terminal) is no problem. This is a bit inconvenient however, since the elements on the line don't get indexed (so the call hierarchy tree isn't always correct, or the highlighting of elements, etc.) Why does Ecipse not like the line as it is? c indexing eclipse-cdt share|improve this question asked Apr 29 '09 at 13:38 Rabarberski 7,960165173 add a comment| 9 Answers 9 active oldest votes up vote 23 down vote accepted Eclipse CDT contains its own preprocessor/parser for analyzing your code and building an index. However, when you invoke a build CDT calls out to your system compiler, like gcc for example. There may be minor differences between the syntax accepted by the CDT parser and the syntax accepted by your compiler. When this happens the CDT parser can get confused. On my system the offsetof macro expands into an expression that uses the __offsetof__ keyword. This keyword isn't recognized by CDT so that's why there's a syntax error. To deal with this problem the CDT parser has a macro built in to deal with __offsetof__ which looks like this: #define __offsetof__(x) (x) This doesn't appear to be correct, at least on my system the result is the removal of the __offsetof__ keyword from the source which still leads to a syntax er
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 http://stackoverflow.com/questions/7968217/eclipse-cdt-syntax-error-on-attribute-keyword 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 http://cboard.cprogramming.com/c-programming/145961-another-mystifying-c-syntax-issue-debug-macro-sharpdefine.html 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 Eclipse CDT syntax error on __attribute__ keyword syntax error up vote 1 down vote favorite 1 I would like to know if there is a way to get rid of CDT syntax error warnings when using gcc's "__attribute__" keyword. It goes without saying that I would not like to switch off CDT syntax check. gcc indexing syntax-error eclipse-cdt share|improve this question edited Nov 29 '11 at 12:52 asked Nov 1 '11 at 14:45 ziu 1,5471331 add eclipse cdt macro a comment| 4 Answers 4 active oldest votes up vote 2 down vote +50 I've not tried it, and I've not used Eclipse for some time, but here's an idea: In the CDT settings for Eclipse (or maybe just your project) set up a predefined macro (I seem to remember you can tell it what the compiler auto-defines) named __attribute__ that takes one parameter, and expands to nothing. Maybe I haven't explained that right. Let me try again with an example. Basically, the aim is to define a macro that works like this: #if ECLIPSE_THINKS_THIS_IS_SET_BUT_GCC_DOESNT #define __attribute__(X) /* nothing */ #endif but without putting anything actually in your code. share|improve this answer answered Nov 29 '11 at 10:17 ams 15.3k22655 I'm digging into that. –ziu Nov 29 '11 at 13:33 Thanks for the hint, I solved the problem. I'm posting a straight answer and you're getting the bounty. –ziu Nov 29 '11 at 14:12 Thanks, I'm glad it worked for you. :) –ams Nov 29 '11 at 14:48 add a comment| up vote 2 down vote accepted Project->Properties->C/C++ general->Path and Symbols->Symbols Add-> Name: __attribute__(X) Value: (leave blank) Related links: You can use th
Programming Boards C Programming another mystifying C syntax issue - DEBUG macro - #define Getting started with C or C++ | C Tutorial | C++ Tutorial | C and C++ FAQ | Get a compiler | Fixes for common problems Thread: another mystifying C syntax issue - DEBUG macro - #define Thread Tools Show Printable Version Email this Page… Subscribe to this Thread… Display Linear Mode Switch to Hybrid Mode Switch to Threaded Mode 02-12-2012 #1 jlewand View Profile View Forum Posts Registered User Join Date Feb 2012 Posts 44 another mystifying C syntax issue - DEBUG macro - #define Simply unbelievable. Code: #define DEBUG #ifdef DEBUG #define dg(x) _tprintf(x) #else #define dg(x) do {} while (0) #endif dg ( (_T("parsed node %s %d"), wordwrk, z) ); The above fails because the LAST _tprintf parameter is an INT. Swap the two and the syntax is then OK: dg ( (_T("parsed node %d %s"), z, wordwrk) ); I'm all ears as to why this simply isn't a replacement of dg with _tprintf. Fortunately, I found another better use of macros for debugging: Code: #define NODEBUG2 #ifdef DEBUG2 #define D if(1) #else #define D if(0) #endif D _tprintf(_T(parsed node %s %d"), wordwrk, z); Last edited by jlewand; 02-12-2012 at 11:45 AM. 02-12-2012 #2 oogabooga View Profile View Forum Posts - - - - - - - - Join Date Jan 2008 Posts 2,808 All ears, no brain. If you'd simply learn C you'd know about the comma operator and wouldn't be so mystified. The result of your macros is: Code: _tprintf(("parsed node %s %d", wordwrk, z)); I.e. you're passing to _tprintf a single parameter that uses the comma operator. The comma operator processes each comma separated statement in order and results in only the last one. So if your last one is a string, that will compile since _tprintf expects a string as its first parameter. If the last is an int, that won't compile. But even in the case where the string is the last one, it's not doing what you want it to. 02-12-2012 #3 jlewand View Profile View Forum Posts Registered User Join Date Feb 2012 Posts 44 I've googled C syntax for near a month now. It's very, very cryptic. Remember, I've programmed assembly for 30+ years as well as a half dozen other languages. Nothing remotely compares to C syntax in obtuseness. It's simply hit or miss. I've written assemblers for microprocessors and even commercial software. I was simply using what others have used (this specific