How does the compiler detect the target?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How does the compiler detect the target?

Jump to solution
773 Views
CarlFST60L
Senior Contributor II

Hi,

 

Im sure this is probably simple, I just have not found the answer.

 

I have several targets in one project (CW7.2), when I select a target, I need to change what code compiles without manually defining a name and including that in everything. Something like this:

 

 

#ifdef Target1

.... some code ....

#endif

...some more code ...

#ifdefine Target2

... some more code ...

#endif

 

Is this possible?I have read the help files and came up with nothing...

 

Thanks,

Carl

Labels (1)
0 Kudos
1 Solution
454 Views
CrasyCat
Specialist III

Hello

 

  You can specify the macro you want to use in the Target Setting's C/C++ Preprocessor panel.

 

  - Open the Target Settings dialog (Press ALT+F7)

  - Go to Language Settings > C/C++ Preprocessor panel

  - Add your define in the Prefix Text edit box.

 

For example in the setting for target 1 specify

#define Target1

 

these settings are target specific. So just add the appropriate define for each target.

 

CrasyCat

View solution in original post

0 Kudos
6 Replies
455 Views
CrasyCat
Specialist III

Hello

 

  You can specify the macro you want to use in the Target Setting's C/C++ Preprocessor panel.

 

  - Open the Target Settings dialog (Press ALT+F7)

  - Go to Language Settings > C/C++ Preprocessor panel

  - Add your define in the Prefix Text edit box.

 

For example in the setting for target 1 specify

#define Target1

 

these settings are target specific. So just add the appropriate define for each target.

 

CrasyCat

0 Kudos
454 Views
CarlFST60L
Senior Contributor II

Ahhh, so simple, the worst part is I found I have previously modified this for other reasons!

Thanks,

Carl

0 Kudos
454 Views
CarlFST60L
Senior Contributor II

Hi,

 

How do I modify the Coldfire preprocessor in CW10.1? There appears to be an option for HCS08 projects, but not Coldfire...? And I have done it successfully in CW7.2.

 

Thanks,

Carl Norman

0 Kudos
454 Views
CarlFST60L
Senior Contributor II

Apparently there is nothing available for CW10.1 for coldfire...

 

Here is a work around:

 

https://community.freescale.com/message/80556#80556

0 Kudos
454 Views
CrasyCat
Specialist III

Hello

 

Did you consider creating a .h file containing all the #define for your configuration and specifying it as a prefix file in C-C++ Build > Settings > Tool Settings > ColdFire Compiler > Input > Prefix File edit box.

 

Just switch the prefix file for the other configurations.

 

CrasyCat

0 Kudos
454 Views
CarlFST60L
Senior Contributor II

Thanks, I just ported over to using this Prefix file method as it was getting to messy.

 

Would be nice if the IDE was aware of this, the IDE is unaware of definitions in this file so its also quite useless. Any idea how to get the IDE to be aware of the prefix file?

 

If I do something like this in the prefix file

 

#define _TEST_

 

Then in my code

 

#ifdef _TEST_

#warning TEST

#endif

 

This entire statement is in gray as the IDE is not aware of _TEST_ being defined, yet it highlights the #warning as something is aware the #warning statement is there...

 

 

 

 

 

0 Kudos