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.

CGT error message "invalid designator kind"

Hello,

Customer is using C6474 and CCS4.2.
He has compiler error using some CGT versions as follows.

Source Code: ktime.h

union ktime {
 s64 tv64;
#if BITS_PER_LONG != 64 && !defined(CONFIG_KTIME_SCALAR)
 struct {
# ifdef __BIG_ENDIAN
 s32 sec, nsec;
# else
 s32 nsec, sec;
# endif
 } tv;
#endif
};

typedef union ktime ktime_t;


<line 159>
/* Set a ktime_t variable to a value in sec/nsec representation: */
static inline ktime_t ktime_set(const long32 secs, const unsigned long32 nsecs)
{
 return (ktime_t) { .tv = { .sec = secs, .nsec = nsecs } };/* 未対応 */
}

Error message:
"..\ktime.h", line 159: error: invalid designator kind

Some CGT version don't create above error message for same source code as follows.
CGT 6.1.2  -> No error
CGT 6.1.5  -> No error
CGT 6.1.11 -> Error
CGT 6.1.16 -> Error
CGT 6.1.19 -> Error
CGT 7.0.4  -> Error
CGT 7.2.0  -> No error

Please advice why some CGT versions output above error and another versions don't.

Regards,

  • Designated initializers (".tv = ...") are a C99 feature.  They are not supported in the TI compiler (which supports C89) unless GCC mode (or relaxed mode) is used.  The exact list of features enabled by default, in GCC mode, and in relaxed mode has been changing over the last few releases.  I'm not sure exactly what the story is with this particular feature, but you should be able to get it to work for all of those versions by using the '--gcc' command-line option to enable GCC support.

  • Hello Mr. Archaeologist,

    Thank you for your answer.
    Customer has already using "--gcc" option and has different result for each CGT versions.
    I searched the defect story of CGT but I can't find the explanation why some version appear
    the error in spite of using "-gcc" options.

    Could you please explain the reason of error on some CGT versions.

    Regards.

  • The support for GCC extensions has improved with recent releases of the compiler.  Please see this Wiki article for more detail.

    Thanks and regards,

    -George

  • Designated initializers for unions were not supported until C6X 7.2.0 tools (see http://processors.wiki.ti.com/index.php/GCC_Extensions_in_TI_Compilers).  However, early versions ot the tools did not reject such initializers and would generate incorrect code unless the initializer corresponded to the first member of the union.  At some point (around Aug 2009) this bug was fixed with a check being added to the compiler to reject any designated intializer of a union type.

    This accounts for the results you are seeing.  The early versions of the compiler that gave no error also were unlikely to be generating correct code.