1

compiler version : TI v15.12.1.LTS

Family : ARM

Varient : Tiva TM4C123GH6PM

When try to build c++ class in main.c It is giving below error

**** Build of configuration Debug__TI for project Lab1 ****

"C:\\ti\\ccsv6\\utils\\bin\\gmake" -k all 
'Building file: ../Generic.cpp'
'Invoking: ARM Compiler'
"C:/ti/ccsv6/tools/compiler/ti-cgt-arm_15.12.1.LTS/bin/armcl" -mv7M4 --code_state=16 --float_support=FPv4SPD16 -me --include_path="C:/ti/ccsv6/tools/compiler/ti-cgt-arm_15.12.1.LTS/include" -g --gcc --define=ccs="ccs" --define=PART_TM4C123GH6PM --diag_wrap=off --diag_warning=225 --display_error_number --abi=eabi --preproc_with_compile --preproc_dependency="Generic.d"  "../Generic.cpp"
'Finished building: ../Generic.cpp'
' '
'Building file: ../main.c'
'Invoking: ARM Compiler'
"C:/ti/ccsv6/tools/compiler/ti-cgt-arm_15.12.1.LTS/bin/armcl" -mv7M4 --code_state=16 --float_support=FPv4SPD16 -me --include_path="C:/ti/ccsv6/tools/compiler/ti-cgt-arm_15.12.1.LTS/include" -g --gcc --define=ccs="ccs" --define=PART_TM4C123GH6PM --diag_wrap=off --diag_warning=225 --display_error_number --abi=eabi --preproc_with_compile --preproc_dependency="main.d"  "../main.c"

>> Compilation failure
subdir_rules.mk:14: recipe for target 'main.obj' failed
"..\Generic.h", line 11: error #20: identifier "class" is undefined
"..\Generic.h", line 11: error #66: expected a ";"
"..\Generic.h", line 15: warning #12-D: parsing restarts here after previous syntax error
"../main.c", line 6: error #20: identifier "generic" is undefined
3 errors detected in the compilation of "../main.c".
gmake: *** [main.obj] Error 1
'Building file: ../tm4c123gh6pm_startup_ccs.c'
'Invoking: ARM Compiler'
"C:/ti/ccsv6/tools/compiler/ti-cgt-arm_15.12.1.LTS/bin/armcl" -mv7M4 --code_state=16 --float_support=FPv4SPD16 -me --include_path="C:/ti/ccsv6/tools/compiler/ti-cgt-arm_15.12.1.LTS/include" -g --gcc --define=ccs="ccs" --define=PART_TM4C123GH6PM --diag_wrap=off --diag_warning=225 --display_error_number --abi=eabi --preproc_with_compile --preproc_dependency="tm4c123gh6pm_startup_ccs.d"  "../tm4c123gh6pm_startup_ccs.c"
'Finished building: ../tm4c123gh6pm_startup_ccs.c'
' '
gmake: Target 'all' not remade because of errors.

**** Build Finished ****

class details are :

main.c

#include "Generic.h"

int main(void) {

    Generic *generic;
    return 0;
}

Generic.cpp

#include "Generic.h"

Generic::Generic() {
    // TODO Auto-generated constructor stub

}

Generic::~Generic() {
    // TODO Auto-generated destructor stub
}

Generic.h

#ifndef GENERIC_H_
#define GENERIC_H_

class Generic {
public:
    Generic();
    virtual ~Generic();
};

#endif /* GENERIC_H_ */

I am not sure whether we need to make main.c to main.cpp. If that is so then which make file need to updated for main.cpp

Any help on c++ compilation for ARM

Sachin
  • 501
  • 10
  • 18
  • `armcl` seems to have a `--cpp_default` command line option, you could try that if you absolutely cannot rename your main.c – Karsten Koop May 31 '16 at 07:22

1 Answers1

1

From TI forum :

By default the TI ARM compiler uses the file extension to determine if to compiler a source code as C or C++. If this is a CCS project, you can just rename main.c to main.cpp and the CCS generated makefile will be updated automatically.

This works now. Thanks.

Sachin
  • 501
  • 10
  • 18