Author Topic: How to setup conditional define in "C/C++ preprocessing" option?  (Read 8529 times)

skywolf

  • Community Member
  • Posts: 22
  • Hero Points: 0
How to setup conditional define in "C/C++ preprocessing" option?
« on: September 05, 2008, 04:46:55 am »
Following defines are used for defferent target:
#if TARGET_TYPE==TARGET_ARM7
    #define _PARKED             __packed     //structure qualifier
    #define DefIPVar(var)       DWORD var  //type define for IP Address
#elif TARGET_TYPE==TARGET_C6000
    #define _PARKED
    #define DefIPVar(var)       BYTE var[4]
#endif

_PARKED and DefIPVar must be add to "C/C++ preprocessing" option, otherwise "tag not found" error would rise when reference structure/variable. However, only simple define can be add in "C/C++ preprocessing". Is there any solution?

Graeme

  • Senior Community Member
  • Posts: 2724
  • Hero Points: 337
Re: How to setup conditional define in "C/C++ preprocessing" option?
« Reply #1 on: September 08, 2008, 12:05:36 pm »
Following defines are used for defferent target:
#if TARGET_TYPE==TARGET_ARM7
    #define _PARKED             __packed     //structure qualifier
    #define DefIPVar(var)       DWORD var  //type define for IP Address
#elif TARGET_TYPE==TARGET_C6000
    #define _PARKED
    #define DefIPVar(var)       BYTE var[4]
#endif

_PARKED and DefIPVar must be add to "C/C++ preprocessing" option, otherwise "tag not found" error would rise when reference structure/variable. However, only simple define can be add in "C/C++ preprocessing". Is there any solution?


If you search the help file for usercpp you'll find the following in the C/C++ preprocessing topic

Quote
Preprocessor macros are stored in usercpp.h, located in your configuration directory. Rather than using the dialog, you can add large numbers of #defines directly to this file. You may want to make sure that your entire development team has an up-to-date copy of this configuration file once you have added all of your local preprocessor macros.

NOTE The usercpp.h file should only be used for #defines and #undefs—not #includes.

So you see you can directly edit usercpp.h.  This allows you to have this in usercpp.h


    //  TARGET_TYPE==TARGET_ARM7
    #define _PARKED             __packed     //structure qualifier
    #define DefIPVar(var)       DWORD var  //type define for IP Address

    //TARGET_TYPE==TARGET_C6000
    //#define _PARKED
    //#define DefIPVar(var)       BYTE var[4]

You can manually edit usercpp.h when you want to change builds - uncomment and comment the appropriate #defines.  You can also maintain separate files - one for each target, and overwrite usercpp.h with one of them, according to the build  - if you see what I mean.  It's also possible to write a slick macro to automate this to some extent.

Graeme