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__, __LINE__, __FUNCTION__, and __func__

testing the above with c6runapp-cc for debugging purposes, I find that these work:

__FILE__, __FUNCTION__

but these do not work:

__LINE__, __func__

any idea why?

  • Can you elaborate on what you mean by not working.  I don't see any issue building code that uses these macros, but I haven't tried running resulting program.  Note that according to the Compiler User's Guide, only __FILE__ and __LINE__ are listed as predefined macros, so I am a little surprised that __FUNCTION__ and __func__ don't throw any errors.

    I just tried building a simple example to run on a simulator under CCS. The following lines of code:

    printf("FileName: %s\n",__FILE__);
    printf("LineNumber: %d\n",__LINE__);
    printf("FunctionName: %s\n",__FUNCTION__);
    printf("FunctionName: %s\n",__func__);

     Produce the following output:


    FileName: ../src/main.c
    LineNumber: 204
    FunctionName: main
    FunctionName: main

    The C6000 compiler used was v7.3.1. Based on the above, I would suppose that you should see similar results using the same compiler release.  I'll have to check with the compiler team about the undocumented __FUNCTION__ and __func__ support.

    Regards, Daniel

  • Please see this post:

    http://e2e.ti.com/support/development_tools/compiler/f/343/t/158491.aspx

    It turns out my test was built with the --gcc option, so that is why __func__ worked just fine for me.

    Regards, Daniel

  • turns out i was using %s instead of the proper %d, and forgot to include <stdio.h> in the file i was trying to use __func__ so I'm good.

    doc needs to be updated, but this is all stock gcc (or c99) functionality so it shouldn't be removed. 

    thanks!