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/TMS320F28335: C++ code error in CCS

Part Number: TMS320F28335
Other Parts Discussed in Thread: C2000WARE, CONTROLSUITE

Tool/software: Code Composer Studio

Greetings Everyone!

Hope this finds you very well.

I have a working TI-RTOS project based on 'C' language in which there are multiple source code and header files. Now I have to convert that into Object Oriented Programming based code.

 I tried creating a class of a module in code. For that I added a new source code file with .cpp extension and its header file with .hpp extension. The problem is when I create a class in .cpp file it works well and I can create its objects also but when I try to create class in .hpp file then it gives following error: 

#20 identifier "class" is undefined SoC.hpp 
#66 expected a ";" SoC.hpp 
gmake: *** [BMSmain.obj] Error 1
gmake: Target 'all' not remade because of errors.

While I am creating a class like this:

#include "DSP2833x_Device.h"

#ifndef SOC_HPP_
#define SOC_HPP_

class SoC{
    private:
        double          dt;
        unsigned long   diff;

    public:
        SoC();
        ~SoC();
        void estimateSoC(Battery_Data **data);
};

#endif /* SOC_HPP_ */

I have also used a wrapper function to call any function defined in this class from a C code. 

Tools I am using are:

  • CCS 8.1.0
  • Compiler: TI v18.1.2.LTS
  • C2000Ware 1.0.5.00
  • TI-RTOS 2.16.1.14
  • XDAIS 7.21.1.07 
  • SYS/BIOS 6.73.1.01
  • XDCtools 3.50.8.24_core

Second issue is when I define any RTOS task or clock function in .cpp file it gives follwing error:

  • #10010 null: errors encountered during linking; "MBMS_0v1_021118_CPP_f28335.out" not built
  • #10234-D</a> null: unresolved symbols remain
  • gmake: *** [MBMS_0v1_021118_CPP_f28335.out] Error 1
  • gmake: Target 'all' not remade because of errors.
  • unresolved symbol _Clk_Fxn, first referenced in C:\Users\Assad\workspace_v8\MBMS_0v1_021118_CPP\MBMS_F28335\configPkg\package\cfg\app_f28335_p28FP.o28FP
  • unresolved symbol _EEPROMwriteTask_Periodically, first referenced in C:\Users\Assad\workspace_v8\MBMS_0v1_021118_CPP\MBMS_F28335\configPkg\package\cfg\app_f28335_p28FP.o28FP
  • unresolved symbol _IdleTask, first referenced in C:\Users\Assad\workspace_v8\MBMS_0v1_021118_CPP\MBMS_F28335\configPkg\package\cfg\app_f28335_p28FP.o28FP

Is there any other method to do so? If yes then please suggest.

Please help me in this problem.

Your replies will be strongly appreciated. 

Many thanks for your kind consideration.

  • The compiler uses the file extension to decide whether a source file contains C code or C++ code.  Generally, .c means C code, and .cpp means C++ code.  But this applies only to files the compiler sees on the command line.  It does not apply to header files presented with #include  For instance, the following is not the case ...

    /* Things do NOT work this way */
    #include "cpp_header.hpp"  /* C++ */
    #include "c_header.h"      /* C   */

    What governs how an include file is compiled?  The extension of the source file which includes it.  A header file included within file.cpp is compiled as C++.  The same header file included within file.c is compiled as C.  The file extension of the header file does not affect anything.

    So this ...

    Assad Mahmood67 said:
    #20 identifier "class" is undefined SoC.hpp 
    #66 expected a ";" SoC.hpp 

    ... is probably caused by a header file which has C++ code being included in a file with the extension .c .  

    Assad Mahmood67 said:
    unresolved symbol _Clk_Fxn

    The usual cause of this error ... The function Clk_Fxn is defined inside a C++ file, but without the extern "C" qualifier.  For more on this issue, and others like it, please see this collection of FAQ's (not from TI) on how to mix C and C++ code.

    Thanks and regards,

    -George

  • Hello George:

    Thank you very much for replying. Your reply was very helpful for me and it solved my compilation errors problem. 

    But now I am facing another issue just after code compilation which is I am getting a warning

    "Data is being written to auto-generated file null: Data is being written to auto-generated file" 

    And now when I Program/Debug code into the chip it neither shows that code is being programmed nor it shows that flash sectors are being erased before program loading and it also disables the code play & pause button in debug window. 

    This is strange for me.

    Please help me in this issue.

    Following is being displayed at the end of console after code compilation/building:

    Building target: "MBMS_0v1_021118_CPP_f28335.out"
    Invoking: C2000 Linker
    "C:/ti/ccsv8/tools/compiler/ti-cgt-c2000_18.1.2.LTS/bin/cl2000" -v28 -ml -mt -Ooff --advice:performance=all --define=xdc__strict -g --diag_warning=225 --diag_wrap=off --display_error_number -z -m"MBMS_0v1_021118_CPP_f28335.map" --heap_size=0x2400 --stack_size=0x1000 --warn_sections -i"C:/ti/c2000/C2000Ware_1_00_05_00/device_support/f28335/headers/include" -i"C:/ti/ccsv8/tools/compiler/ti-cgt-c2000_18.1.2.LTS/include" -i"C:/ti/ccsv8/tools/compiler/ti-cgt-c2000_18.1.2.LTS/lib" --priority --reread_libs --diag_suppress=16002 --diag_wrap=off --display_error_number --xml_link_info="MBMS_0v1_021118_CPP_linkInfo.xml" --rom_model -o "MBMS_0v1_021118_CPP_f28335.out" "./ADC_Control.obj" "./BMS_Control.obj" "./BMSmain.obj" "./Balancing.obj" "./Battery.obj" "./ContactorOperation.obj" "./DSP2833x_CpuTimers.obj" "./DSP2833x_ECan.obj" "./EEPROM.obj" "./GPIOControl.obj" "./HuaweiRectifierControl.obj" "./Initialization.obj" "./InterruptControl.obj" "./JSON.obj" "./LogControl.obj" "./PWMcontrol.obj" "./SOC_calculation.obj" "./SoC.obj" "./SoC_Wrapper.obj" "./WatchDog.obj" "./logging.obj" "./pid_reg3.obj" "./ApplicationLayer/application.obj" "./CO_driver/CO_driver.obj" "./CO_stack/CANopen.obj" "./CO_stack/CO_Emergency.obj" "./CO_stack/CO_HBconsumer.obj" "./CO_stack/CO_NMT_Heartbeat.obj" "./CO_stack/CO_PDO.obj" "./CO_stack/CO_SDO.obj" "./CO_stack/CO_SDOmaster.obj" "./CO_stack/CO_SYNC.obj" "./CO_stack/crc16-ccitt.obj" "./ControlAPIs/RealtimeParameter.obj" "./DSP2833x_ware/DSP2833x_ADC_cal.obj" "./DSP2833x_ware/DSP2833x_Adc.obj" "./DSP2833x_ware/DSP2833x_CodeStartBranch.obj" "./DSP2833x_ware/DSP2833x_ECap_MCU.obj" "./DSP2833x_ware/DSP2833x_EPwm.obj" "./DSP2833x_ware/DSP2833x_GlobalVariableDefs.obj" "./DSP2833x_ware/DSP2833x_Sci.obj" "./DSP2833x_ware/DSP2833x_Spi_MCU.obj" "./DSP2833x_ware/DSP2833x_SysCtrl.obj" "./DSP2833x_ware/DSP2833x_usDelay.obj" "./Object_Dictionary/CO_OD.obj" "../DSP2833x_Headers_BIOS_Ramfuncs_flash.cmd" -l"configPkg/linker.cmd" -l"C:/ti/controlSUITE/libs/math/IQmath/v160/lib/IQmath_fpu32.lib" -lrts2800_fpu32.lib
    <Linking>
    Finished building target: "MBMS_0v1_021118_CPP_f28335.out"

    Building files: "MBMS_0v1_021118_CPP_f28335.out"
    Invoking: C2000 Hex Utility
    "C:/ti/ccsv8/tools/compiler/ti-cgt-c2000_18.1.2.LTS/bin/hex2000" -o "MBMS_0v1_021118_CPP_f28335.hex" "MBMS_0v1_021118_CPP_f28335.out"
    Translating to Extended Tektronix format...
    "MBMS_0v1_021118_CPP_f28335.out" .text ==> .text
    "MBMS_0v1_021118_CPP_f28335.out" .econst ==> .econst
    "MBMS_0v1_021118_CPP_f28335.out" .cinit ==> .cinit
    "MBMS_0v1_021118_CPP_f28335.out" ramfuncs ==> ramfuncs
    "MBMS_0v1_021118_CPP_f28335.out" .switch ==> .switch
    "MBMS_0v1_021118_CPP_f28335.out" IQmath ==> IQmath
    "MBMS_0v1_021118_CPP_f28335.out" codestart ==> codestart
    warning: Data is being written to auto-generated file
    MBMS_0v1_021118_CPP_f28335.x01
    Finished building: "MBMS_0v1_021118_CPP_f28335.out"

    **** Build Finished ****