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

StackOverflow https://stackoverflow.com/questions/7602791

  •  05-02-2021
  •  | 
  •  

Domanda

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?

È stato utile?

Soluzione

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

Altri suggerimenti

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__

is defined during CDT editor preprocessing stage (works at least with Indigo SR2)

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top