This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

How to define a macro with variable parameters

Other Parts Discussed in Thread: OMAPL138

HI

I want to define a debug macro in ccs, like this

  1. #define __DEBUG__  
  2. #ifdef __DEBUG__  
  3. #define DEBUG(format,...) printf("File: "__FILE__", Line: %05d: "format"/n", __LINE__, ##__VA_ARGS__)  
  4. #else  
  5. #define DEBUG(format,...)  
  6. #endif 

But CCS compile won't recognize with ##__VA_ARGS__ macros, how to reslove it ? 

Thanks a lot

  • You want GCC style variadic macros. According to document SPRU187, the C6000 compiler can support this if you enable GCC extensions in your project properties.
  • Hi e-way,

    As Norman said, you can enable the ##__VA_ARGS__ macros support in C6000 compiler settings of CCS.

    CCS properties -> CCS Build -> C6000 Compiler -> Language options -> Enable support for GCC extensions

    Check the attached screen shot.

    Code:

    DEBUG("TESTing DEBUG %d \n",i);

    Log:

    [ARM9_0] File: C:/ti/OMAPL138_StarterWare_1_10_04_01/examples/lcdkOMAPL138/gpio/gpioCardDetect.c, Line: 00089: TESTing DEBUG 0