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.

Compiler/TMS320F28022: Prototype defined but not called in project optimized without memory allocation in CCS7 @ CGT LTS16.9.3

Part Number: TMS320F28022

Tool/software: TI C/C++ Compiler

Hi Team,

  My customer reported an issue that:  Prototypes will be optimized without memory allocation in CCS7@CGT_16.9.3 which defined in project A and located in F28022 sector A but not called by project A but called by project B located in sector B/C/D,  and caused project B run to unexpected ISR;   but the issue not happened with the CCS5@CGT6.0.2,

  Support Need:

  1. Guidelines to using CCS7@LTS16.9.3 to realize the feature:   Prototypes defined in project A located in sector A but not called in project, the prototypes called by project B located in sector B/C/D;

  Prototype optimized issue.docx

  • I need to clarify some terms.  A function declaration indicates a function of that name exists ...

    int fxn(); /* old-style function declaration */

    A function definition starts like the declaration, but include the implementation of the function ...

    int fxn(int arg)  /* function definition */
    {
        return arg + 10;
    }

    A function prototype is also a function declaration, but includes information about the function arguments ...

    int fxn(int arg);  /* function prototype */

    Function prototypes were introduced into the C language a long time ago.  By now, old-style function declarations are seen only in very old code.  Thus the terms declaration and prototype effectively mean the same thing.  In most of my reading and writing, the term declaration dominates, but the term prototype is understood.

    It is clear, from context, that where this customer uses the term function prototype, he (or she) means function definition.  So, I will use the term definition from this point on.

    I'm not completely certain about what is happening.  I suspect that, somehow, building with the older compiler does not use the option --gen_func_subsections, and building with the new compiler uses the option --gen_func_subsections.  Please read more about that option in the C2000 compiler manual.  If --gen_func_subsections is used, and a function is never called, it is excluded from the final linked program.  The best way to defeat this behavior is by applying #pragma RETAIN to a function that should never be removed.  Please read about #pragma RETAIN in the same compiler manual.

    In summary: If --gen_func_subsections is being used, the fix is to apply #pragma RETAIN to the function definitions which should never be removed.

    Thanks and regards,

    -George