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/TMS320F28377S: Array initialization

Part Number: TMS320F28377S

Tool/software: TI C/C++ Compiler

Hello,

We are using functions from the C library that make use of the sigTable array, which gets initialized as follows:

static __sighandler_t *sigTable[NSIG] = {0};

The issue we found is that the compiler/library is not initializing the whole array with zeros, just a few words of it, and most of the array stays with random data.

It seems to be C standard that the = {0} initializes the whole array to 0s, and not just the first word/s. But the C compiler/library is not doing it.

We tried different compiler versions and they all do the same.

Is there an easy explanation for this behavior?

Thanks,

Max

  • Hello Max,

    You'd better wait until compiler specialist come to the thread. But before that I'd like to let you know there might be peculiarities in the way the standard was implemented. At least in my C6000 world I know that:

    6.13. Initializing Static and Global Variables in COFF ABI Mode

    The ANSI/ISO C standard specifies that global (extern) and static variables without explicit initializations must be initialized to 0 before the program begins running. This task is typically done when the program is loaded. Because the loading process is heavily dependent on the specific environment of the target application system, in COFF ABI mode the compiler itself makes no provision for initializing to 0 otherwise uninitialized static storage class variables at run time. It is up to your application to fulfill this requirement.

    Note

    Initialize Global Objects

    You should explicitly initialize all global objects which you expected the compiler would set to zero by default.

    In C6000 EABI mode the uninitialized variables are zero initialized automatically.

    So despite our understanding of standard requirement, implementation might involve programmer responsibility too.

    Again, you'd better see your compiler manual and/or wait for F28xx guru.

  • The C28x compiler only supports COFF ABI.  (That will change soon.)  Therefore, all the COFF ABI details apply.  For more discussion of this issue, please see the article Uninitialized Static Objects Not Set to Zero in COFF.

    Thanks and regards,

    -George