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.

CCS/CCSTUDIO-C2000: Question about how external #define references are resolved

Part Number: CCSTUDIO-C2000


Tool/software: Code Composer Studio

Hello,

To gain insight into my question I created a simple file.  The file contains two #defines and an empty function.

Each of the #defines is merely used to rename an existing #define from TI include files to shorten the name for convenience.

For example:

#define CTOM_STS1    IPC_CTOMIPCSTS_IPC1          // rename for bits in the status register

IPC_CTOMIPCSTS_IPC1 is #defined in \...\v207\MWare\inc\hw_ipc.h.  I am not including that file in my source code and yet it compiles without errors.

Include File browser shows no include files for my source.  But mouse hovering over IPC_CTOMIPCSTS_IPC1 and pressing F3 to Open Declaration finds and opens the hw_ipc.h file every time.

How does CCS know where to find a #define when the file it's located within is NOT included?  It seems like any other time I would get some warning or error from the tools.

Thank you and best regards,

Steve C.

  • Stephen,

    If you were to use IPC_CTOMIPCSTS_IPC1 in the body of a function you would get an error from the C compiler.  However using it in a #define line won't give an error.

    For example here is a similar bit of code.  The #define line is ok.  But as soon as I try to use either JOHN or IPC_CTOMIPCSTS_IPC1 in my code then I would get an error.  I am not a compiler expert but I believe the #define just tells the preprocessor to replace instances with the defined value.  i.e. replace JOHN with IPC_COMPIPCSTS_IPC1.

    If you are using CTOM_STS1 in your code then I would expect an error.  If you are not getting an error then a file that defines IPC_CTOMIPCSTS_IPC1 must be getting included somehow, or it could be defined in the build options.

    The editor finding the definition could be because there is another project in the workspace that has it. 

    If you could export the project and attach I could try to reproduce here.

    Regards,

    John

  • Thanks John,
    Yeah, the files NOT reporting any error are also NOT referencing the redefine. The file that does use the define also does include the correct headers. If I comment out those includes then the file compiles with errors as expected and proven by you above.
    Best regards,
    Steve