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.

using ENUM in CCS6



Hi,

i'm trying to use ENUM in CCS6 in order  implement a simple state machine (based on switch\case).

i get many many error. 

for example:

"C:/ti/ccsv6/tools/compiler/ti-cgt-c2000_15.9.0.STS/include/e_exception", line 33: error #20: identifier "class" is undefined"

and many more.

does CCS6 doesn't support ENUMs?

br,

Israel

  • Hello Israel,

    You're probably trying to compile c++ code that  is contained in a file that has a .c extension.  

    You could either select "Treat C files a C++ files" at CCS Build->C2000 Compiler->Advanced Options->Language Options located in the project properties or change the extension of your files to .cpp.  

    Stephen

  • Hello Israel,

    Please select verify If the post above helped you solve your problem.

    Thanks,
    Stephen

  • Hi Stephen,
    sorry for my late response.

    i tries to save as CPP. but i get new errors because of it.
    i took a file i already compiled and downloaded in the past to the device, and changed its extension to ".cpp"
    this is what i'm getting:
    "
    undefined first referenced
    symbol in file
    --------- ----------------
    InitPieCtrl() ./Lab6_tryin_SM.obj
    InitPieVectTable() ./Lab6_tryin_SM.obj
    InitSysCtrl() ./Lab6_tryin_SM.obj

    error #10234-D: unresolved symbols remain

    error #10010: errors encountered during linking; "Lab6.out" not built
    >> Compilation failure
    gmake: *** [Lab6.out] Error 1
    gmake: Target `all' not remade because of errors.

    **** Build Finished ****
    "
    do i need to change all my code when going to cpp type?

    br,
    Israel
  • C++ mangles names (variables,function, structures and etc).  Consequently, cpp files and c files won't be able to see each other's variable or function names.  

    You can either change all the source files to have a cpp extension or select  "Treat C files a C++ files" in the project build settings , i.e.  CCS Build->C2000 Compiler->Advanced Options->Language Options located in the project properties.

  • If you absolutely need to compile the .c files as c files (i.e. you are including other peoples code that will not compile as c++ without errors), you could either modify the .c to compile as c++ or modify your c++ header files to have the following shown below.

    Stephen

    #ifdef __cplusplus
    extern "C" {
    #endif
    
    // Header file contents should go here.  
    // The include guard should go outside of the #ifdef __cplusplus. 
    
    #ifdef __cplusplus
    }
    #endif /* extern "C" */

  • You could also change the build properties of individual files, i.e. by right clicking on file and selecting properties.  If you do so, a little wrench symbol will appear on the file icon.  However, that might get confusing, especially if an person inexperienced with code composer is required to work with the project.

  • Israel, as Stephen originally suggested, you probably have some C++ feature being used in your .c file; I'd guess you are including a header file you don't need. There are two possible solutions: remove the C++ feature from your C file, or convert the whole file to a C++ file. The posts in this thread have been focusing on how to deal with converting the file to a C++ file. You might find it easier to split the file into smaller parts, one part which uses C++ features, and one which does not. Make sure to name the files with .cpp and .c filename extention, respectively.