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.

__FILE__ without full path



I'm using the __FILE__ and __LINE__ macros to log the origins of errors in the application. Can I configure CCS 5.1 so that only the file name (without path) is replaced by the __FILE__ macro?

  • The __FILE__ macro expands to the name of the current input file via the path used by the preprocessor to open the file. So it may not necessarily always be the just the file name, as it could be the relative path or absolute path depending on what is passed to the compiler. I don't think there is a way to have it expand to just the file name.

  • What about the __MODULE__ macro? This would exactly fulfil my needs. But the CCS5.1 throws the following error:
        error #20: identifier "__MODULE__" is undefined

    The __MODULE__ macro should be supported by the ARM C and C++ compilers according to the chapter 3.6. (predefined macros) of the ARM Compiler Reference.

  • Unfortunately the __MODULE__ macro does not seem to be supported by the TI compiler tools. Please see the Compiler Users Guide (section 2.6.1) for the list of supported predefined macros.

  • Hi Daniel,

    I'm working with CCS 5.3.0.
    The following solution works fine for me:

    - Go to PROJECT -> PROPERTIES -> CCS Build -> ARM Compiler -> Advanced Options -> Predefined Symbols
    - Add    FILENAME_IN_ECLIPSE_PROJECT="\"${InputFileName}"\"

    Now, you can use the  FILENAME_IN_ECLIPSE  symbol  (like __FILE__).
    (It will expand to the file name only - without path)

    e.g.:   Put the following line in every source file of your project:

    static const  char  AC_ModuleName[] = FILENAME_IN_ECLIPSE_PROJECT;

    or something like that:

    error_write(FILENAME_IN_ECLIPSE_PROJECT, __LINE__, -1);

    Regards, Andy

    PS:
    Solution idea comes from the following thread:
    http://e2e.ti.com/support/development_tools/code_composer_studio/f/81/t/183984.aspx