简体   繁体   中英

Is there a way to #define a C macro that is only defined while in an Eclipse editor window?

I'm using Eclipse Galileo with CDT for C development targeting embedded devices.

Like so many other compilers targeted at µcontrollers, the IAR compiler uses some non-standard variable types that Eclipse/CDT doesn't recognize and flags them as problems. Since these variable types are the foundations of other variable types I use the problem cascades to the point that just about every line using variables declared with the non-standard types are flagged as having syntax problems, even when the syntax is correct. It's not a critical problem, but it is definitely a nuisance.

  1. Is there a setting within Eclipse/CDT where I can add non-standard syntax, or...

  2. Is there some predefined macro within Eclipse/CDT that I can access with something like #ifdef SECRET_ECLIPSE_MACRO ... for conditionally setting or clearing a macro with the string of the offending variable type definition?

Well, you can go the other way around. Define a NOT_ECLIPSE macro when you compile your code, and check for its non-existence in your code. If it's not defined, you're in Eclipse.

Is there some predefined macro within Eclipse/CDT that I can access

Yes, there are many.

See this page. http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse.cdt.doc.user/reference/cdt_u_prop_build_variables.htm

Don't forget to check the 'SHow system variables' option.

__CDT_PARSER__

在 CDT 编辑器预处理阶段定义(至少适用于 Indigo SR2)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM