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/TMS320F28379D: Compiler Remark: Declaration cannot appear after an executable statement.

Part Number: TMS320F28379D

Tool/software: Code Composer Studio

I have a function that implements a control algorithm. I need a few matrices in this algorithm so I have put their definitions into a header file so that I can alter the matrix initialization values easily. My function then looks like this:

void control_algorithm(int some_inputs)
{
int some_simple_integer_variable;

#include "header_with_matrix_in_it.h"

// Function then does other things without issue...

return;
}

The header file looks like this:

#ifndef HEADER_WITH_MATRIX_IN_IT_H
#define HEADER_WITH_MATRIX_IN_IT_H

    static comp_num * H[1];
    static comp_num H_row_zero[3] =
    {
     [0].real = 0,
     [0].imag = 0,
     [1].real = 1,
     [1].imag = 0,
     [2].real = 1,
     [2].imag = 0,
    };

    H[0] = H_row_zero;

#endif /* HEADER_WITH_MATRIX_IN_IT_H*/

When I compile with remarks enabled in the compiler flags, I get a remark on everything in the header file saying that a declaration cannot appear after an executable statement. Why is this?

My understanding is that the contents of the .h file are copied verbatim in place of the #include statement before the compiler is even invoked. There are no executable statements before the #include statement. 

  • I am unable to reproduce the problem.

    Another way you can see the problem ... Build with the option --gen_preprocessor_listing.  This creates a preprocessor listing file.  It has the same name as the source file, with the extension changed to .rl.  Every line starts with a capital letter which identifies it.  For more details, please search for the option in the C28x compiler manual.  

    If that does not resolve the problem, then please submit a test case.  For the problem source file, please follow the directions in the article How to Submit a Compiler Test Case.

    Thanks and regards,

    -George

  • Thanks George,

    I have enabled the --gen_preprocessor_listing option and I will investigate further tomorrow. I will try to isolate the problem in a simpler test case, as the preprocessor listing in this case with all the headers copied in is over 30000 lines in length.