Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Defining environment variable in Eclipse

Status
Not open for further replies.

ep.hobbyiest

Full Member level 4
Full Member level 4
Joined
Jul 24, 2014
Messages
212
Helped
1
Reputation
2
Reaction score
1
Trophy points
18
Activity points
1,487
Hi,

I have recently started to use Eclipse and found very user friendly. But as i m new, i m facing some problem. Like setting some Variables.

I bunch of .c and .h files. And at the beginning of the file i have check like
#ifdef PROCESSOR,

so, to make this file accessible i have to define #define PROCESSOR in each file, which is very time consuming every time(because i m using latest version of workspaces, so, need to browse new workspace every time).

So i want to know, easiest way to define PROCESSOR in the somewhere in the eclipse setting, so no need to #define in each file.
 

There are a few possible options, one option, my preference, would be to define a symbol, not an environment variable:

1. Right click the current project folder/directory and select Properties.

2. While in the properties dialog window, expand C/C++ General menu on the left side of the dialog window, then select Paths and Symbols.

3. Click Add on the far right, enter Name, and Value if required, check both the Add to all configurations and Add to all languages options.

DefinePreprocessorSymbol.JPG

4. Click Apply you should then see the following message box:

DefinePreprocessorSymbol2.JPG

5. Click Yes to rebuild the project with the newly defined symbol, you should see the symbol defined in the resulting compiler messages:

DefinePreprocessorSymbol3.JPG

Another option is to define a compiler flag, -D flag option, the drawbacks to this method. the flag must be defined for all languages used, C and C++, and any future changes require the compiler flag be edited for any language for which it is defined.

1. Right click the current project folder/directory and select Properties.

2. While in the properties dialog window, expand C/C++ Build menu on the left side of the dialog window, then select GCC C++ Compiler and Miscellaneous.

3. Enter the required -D compiler flag, with the symbol name, and value if required, as below, in the Other flags text box on the right:

Code:
-DPROCESSOR=x64

DefinePreprocessorSymbol4.JPG

4. Repeat the above steps for the GCC C Compiler option and its associated Miscellaneous.

4. Then clean and rebuild the project, the compiler flag should be visible in the compiler messages:

DefinePreprocessorSymbol5.JPG


BigDog
 
Great !!!
Thanks. It is working.
Do you have any same kind of trick which will make coding easy.
 

Do you have any same kind of trick which will make coding easy.

Apart from learning to write routines which can be easily ported to other platforms for repeated use, the best advice I can give:

1. Practice

2. Practice some more.

3. Practice till a state of Zen is reached.


BigDog
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top