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.

Predefined Compiler Symbols



I am using CCS6.1.0 and some third party source code that builds based on the compiler definition.  When using the 5.1.x compilers, the compiler is able to resolve the following line of code and define the correct options inside the elif statement.

#elif (defined(__TMS470__)

When I select any of the 5.2.x version compilers, this line no longer is defined.  In reading through the compiler documentation for 5.2 (http://www.ti.com/lit/ug/spnu151j/spnu151j.pdf) the old TMS470 is not in the predefined ARM macro names in section 5.2.1 of the document.  There is a note at the end of the list that says:

NOTE: Macros with names that contain __TI_ARM are duplicates of the older __TI_TMS470 macos.  For example, __TI_ARM_V7__ is the newer name for __TI_TMS470_V7__ macro.  The old macro names still exist and can continue to be used.

The last note does not appear to be correct but even if I change the line of code to the following:

#elif (defined(__TMS470__) || defined(__TI_ARM__)) || defined(__TI_ARM_VM4))

it still doesn't compile.  Why can't I get the 5.2.x compilers to work in my project?  The maximum version I can use is 5.1.11 which defines the __TMS470__ so it will build.  Here is the General properties page.

  • The "TMS470" versions of the macros are indeed still supported in 5.2.1.  You can verify this by compiling an empty file with the extra option --preproc_macros=macros.pp, which will create a file containing all of the macros pre-defined by the compiler.

    Could you please show us the entire structure of your #if statement?  Something like this:

    #if condition
      #warn case0
    #elif defined(__TMS470__)
      #warn case1
    #else
      #warn case2
    #endif
  • Here is the compiler check.

    #if defined(__AVR__) #define OSCOMPILER OSGCC_AVR #define OSTARGET OSAVR #elif defined(C30) || defined(__C30) || defined(__C30__) #define OSCOMPILER OSMPLAB_C30 #if defined(__PIC24F__) #define OSTARGET OSPIC24F #elif defined(__PIC24H__) #define OSTARGET OSPIC24H #elif defined(__dsPIC30F__) #define OSTARGET OSDSPIC30F #elif defined(__dsPIC33F__) #define OSTARGET OSDSPIC33F #else #define OSTARGET OSPIC24F // default #endif #elif (defined(__TMS470__) || defined(__TI_ARM__)) || defined(__TI_ARM_VM4)) #define OSCOMPILER OSARM_RVDS #define OSTARGET OSARMCM4 #else #define OSCOMPILER OSGCC #define OSTARGET OSIX86 #endif

  • There's an extra close paranthesis on the "#elif ARM" line, which causes a compilation error and the file will not compile at all. I think you want to remove one after __TI_ARM__
    Even so, I do get the ARM case
  • Also, are you sure about the spelling of the last one? I think it should be __TI_ARM_V7M4__
  • You are right and I fixed those items. Still doesn't work though. Works with any 5.1.x but any 5.2.x doesn't work.
  • Found something else.  It looks like it maybe related to a GNUC define.  This statement seems to not be defined in the 5.2.x versus the 5.1.x.  Any ideas about that?

    #if   defined(__GNUC__)

     #undef  OSCOMPILER

     #undef  OSTARGET

  • It looks like there is more to the statement.  It is a messy file with comments all over and terrible alignment.

    #if defined(__GNUC__)
      #undef OSCOMPILER
      #undef OSTARGET
    
      #if  defined(__AVR__)
        #define OSCOMPILER                      OSGCC_AVR
        #define OSTARGET                        OSAVR
      #elif defined(C30) || defined(__C30) || defined(__C30__)
        #define OSCOMPILER                      OSMPLAB_C30  
        #if   defined(__PIC24F__)
          #define OSTARGET                      OSPIC24F
        #elif defined(__PIC24H__)
          #define OSTARGET                      OSPIC24H
        #elif defined(__dsPIC30F__)
          #define OSTARGET                      OSDSPIC30F
        #elif defined(__dsPIC33F__)
          #define OSTARGET                      OSDSPIC33F
        #else
          #define OSTARGET                      OSPIC24F // default
        #endif
      #elif (defined(__TMS470__) || defined(__TI_ARM__) || defined(__TI_ARM_VM4__))
        #define OSCOMPILER                      OSARM_RVDS
        #define OSTARGET                        OSARMCM4
      #else
        #define OSCOMPILER                      OSGCC
        #define OSTARGET                        OSIX86
      #endif
    
    #elif defined(HI_TECH_C)
      #undef OSCOMPILER
      #undef OSTARGET
      #if defined(_PIC12)
        #define OSCOMPILER OSHT_PICC
        #define OSTARGET OSPIC12
      #elif defined(_PIC14)
        #define OSCOMPILER OSHT_PICC
        #define OSTARGET OSPIC16
      #elif defined(_PIC16)
        #define OSCOMPILER OSHT_PICC
        #define OSTARGET OSPIC17
      #elif defined(_PIC18)
        #define OSCOMPILER OSHT_PICC
        #define OSTARGET OSPIC18
      #elif defined(i8051)
        #define OSCOMPILER OSHT_8051C
        #define OSTARGET OSI8051
      #elif defined(_V8)
        #define OSCOMPILER OSHT_V8C
        #define OSTARGET OSVAV8
      #elif defined(__MSP430C__)
        #define OSCOMPILER OSHT_430C
        #define OSTARGET OSMSP430
      #endif
    #endif


    #endif
  • The predefined symbol __GNUC__ is not defined in compiler versions 5.2.x.  See this thread for more detail.

    To debug preprocessor problems generally, I recommend use of the option --gen_acp_raw.  Read more about it in the ARM compiler manual.

    Thanks and regards,

    -George

  • Yes, I seem to recall the behavior of the compiler with respect to whether it generates __GNUC__ has changed. I'll try to gather the details