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.

TMS320F28388D: Is the ARM Enumeration Size Configurable?

Part Number: TMS320F28388D

Greetings,

                I have observed that the CM compiler treats an enumeration as a byte.  This is in contrast to the C28 compilers which define it to be 16 bits.  This means that when the two cores share a header file, that file needs to be updated to work with both compilers.  I have looked, but have not been able to find a compiler option which would configure the ARM enumeration to be 16 bits.  Is there an option to do that?

Thank you,

Ed

  • Is there an option to do that?

    There is.  But it forces all enum types to be 32-bits wide, and not 16-bits wide.  

    Here is a suggestion to consider.  In C++, you can write something like ...

    enum colors : uint16_t { red, green, blue };

    The syntax : name_of_type forces the enum to be of that type.  In this case, uint16_t comes from the standard header file stdint.h.

    This enum feature is introduced in the C++11 standards.  C++11 is supported by both the TI Arm compiler, and the TI Arm Clang compiler.

    Thanks and regards,

    -George

  • Hi George,

                    I found the 32-bit one too.

                    I tried the syntax you suggested, and it seems to work.  But it produces a warning which I can’t get rid of.  I tried changing C2000 Compiler->Advanced Options->Language Options.C Dialect to “compile program in C11 mode (--c11).  Is this the right place?  Is there an additional/alternative place I should be changing?

    Thank you,

    Ed

  • My previous post only applies to the TI Arm compilers, and not the C2000 compiler.  I overlooked this detail from your first post ...

    when the two cores share a header file

    One complication is that the C2000 compiler only supports C++03, and not C++11.  That's why you get the warning.  Here is one way to do it.  I'm sure there are others.

    enum colors
    #ifndef __TMS320C28XX__
    : uint16_t
    #endif
    { red, green, blue };

    The symbol __TMS320C28XX__ is predefined by the C2000 compiler, but not the Arm compiler.

    Thanks and regards,

    -George

  • OK.  That makes sense.  Thank you George.

    Ed