Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [cdt-dev] Setting compilation options to g++

Hello,


sindolfo wrote:
> 
> I'm a beginner with the CDT API and need to pass a -D flag to g++ in my
> CDT Project. Is there a way to set the compilation parameters of a CDT
> project using the CDT API? Could someone post a simple example code here?
> 

Are you talking from a developer or users POV? 

As a user, you project has an options page. Right click on Project and
select properties. Under C/C++ Build->Settings. Look under GCC C++ Compiler
(or respective compiler you are using) and select preprocessor. There is an
option here to set -D flags. This is set on a per project basis.

As a plugin developer, you can set project options on a project being
created by calling ManagedBuildManager.setOption(IConfiguration config,
IHoldsOptions holder, IOption option, String[] value)

Parameters:
config The configuration the option belongs to.
holder The holder/parent of the option.
option The option to set the value for.
value The values the option should contain after the change.

I set this option across all configurations. To modify the GCC C++ Compiler
-D option I talked about earlier, your command would call:
ManagedBuildManager.setOption(config,tools,tools.getOptionById("gnu.cpp.compiler.option.preprocessor.def","foo");

If you aren't sure the id, you can always import
org.eclipse.cdt.managedbuilder.gnu.ui and look at the buildDefinitions
extensions



-----
Forrest Stanley
Project Engineer
http://www.netburner.com NetBurner, Inc 
NBEclipse - Build a network enabled embedded device in one day with an
Eclipse interface!

-- 
View this message in context: http://www.nabble.com/Setting-compilation-options-to-g%2B%2B-tp24517728p24596321.html
Sent from the Eclipse CDT - Development mailing list archive at Nabble.com.



Back to the top