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.

RTOS/CC2650: Renaming "main.c" in "project zero" from simplelink academy 1.11 to "main.cpp" breaks the project

Part Number: CC2650

Tool/software: TI-RTOS

I'd really like to use c++ for my simplink project but doing so seems to break things pretty fundamentally.  It's easy to recreate by simply importing a fresh "project zero" then rename "main.c" to "main.cpp".  As far as I can tell it breaks the "bool" type for icall.h. I'll keep looking for missing "extern "C" lines in the various include files.  Maybe I'm missing a project setting?

Here's the console output:

**** Build of configuration Debug for project project_zero_app_cc2650stk ****

"C:\\ti\\ccsv7\\utils\\bin\\gmake" -j -k -j 8 all -O 
'Building file: ../Startup/main.cpp'
'Invoking: ARM Compiler'
"C:/ti/ccsv7/tools/compiler/ti-cgt-arm_16.9.1.LTS/bin/armcl" --cmd_file="c:/ti/simplelink/ble_sdk_2_02_01_18/src/config/build_components.opt" --cmd_file="D:/projects/testing/project_zero_stack_cc2650/TOOLS/build_config.opt" --cmd_file="D:/projects/testing/project_zero_stack_cc2650/TOOLS/ccs_compiler_defines.bcfg"  -mv7M3 --code_state=16 -me -O4 --opt_for_speed=0 --include_path="D:/projects/testing/project_zero_app_cc2650stk" --include_path="D:/projects/testing/project_zero_app_cc2650stk/Profiles" --include_path="D:/projects/testing/project_zero_app_cc2650stk/Application" --include_path="D:/projects/testing/project_zero_app_cc2650stk/ICallBLE" --include_path="D:/projects/testing/project_zero_app_cc2650stk/Startup" --include_path="D:/projects/testing/project_zero_app_cc2650stk/Board" --include_path="c:/ti/simplelink_academy_01_11_00_0000/modules/projects/support_files/Components/uart_log" --include_path="c:/ti/simplelink/ble_sdk_2_02_01_18/src/examples/simple_peripheral/cc26xx/app" --include_path="c:/ti/simplelink/ble_sdk_2_02_01_18/src/inc" --include_path="c:/ti/simplelink/ble_sdk_2_02_01_18/src/icall/inc" --include_path="c:/ti/simplelink/ble_sdk_2_02_01_18/src/profiles/roles/cc26xx" --include_path="c:/ti/simplelink/ble_sdk_2_02_01_18/src/profiles/roles" --include_path="c:/ti/simplelink/ble_sdk_2_02_01_18/src/profiles/dev_info" --include_path="c:/ti/simplelink/ble_sdk_2_02_01_18/src/profiles/simple_profile/cc26xx" --include_path="c:/ti/simplelink/ble_sdk_2_02_01_18/src/profiles/simple_profile" --include_path="c:/ti/simplelink/ble_sdk_2_02_01_18/src/common/cc26xx" --include_path="c:/ti/simplelink/ble_sdk_2_02_01_18/src/components/heapmgr" --include_path="c:/ti/simplelink/ble_sdk_2_02_01_18/src/controller/cc26xx/inc" --include_path="c:/ti/simplelink/ble_sdk_2_02_01_18/src/components/hal/src/target/_common" --include_path="c:/ti/simplelink/ble_sdk_2_02_01_18/src/components/hal/src/target" --include_path="c:/ti/simplelink/ble_sdk_2_02_01_18/src/components/hal/src/target/_common/cc26xx" --include_path="c:/ti/simplelink/ble_sdk_2_02_01_18/src/components/hal/src/inc" --include_path="c:/ti/simplelink/ble_sdk_2_02_01_18/src/components/osal/src/inc" --include_path="c:/ti/simplelink/ble_sdk_2_02_01_18/src/components/services/src/sdata" --include_path="c:/ti/simplelink/ble_sdk_2_02_01_18/src/components/services/src/saddr" --include_path="c:/ti/simplelink/ble_sdk_2_02_01_18/src/components/icall/src/inc" --include_path="c:/ti/tirtos_cc13xx_cc26xx_2_20_01_08/products/cc26xxware_2_24_02_17393" --include_path="C:/ti/ccsv7/tools/compiler/ti-cgt-arm_16.9.1.LTS/include" --define=USE_ICALL --define=POWER_SAVING --define=SBP_TASK_STACK_SIZE=700 --define=GAPROLE_TASK_STACK_SIZE=520 --define=HEAPMGR_SIZE=0 --define=Display_DISABLE_ALL --define=BOARD_DISPLAY_EXCLUDE_UART --define=xBOARD_DISPLAY_EXCLUDE_LCD --define=ICALL_MAX_NUM_TASKS=3 --define=ICALL_MAX_NUM_ENTITIES=6 --define=xdc_runtime_Assert_DISABLE_ALL --define=Xxdc_runtime_Log_DISABLE_ALL --define=MAX_NUM_BLE_CONNS=1 --define=CC26XX --define=xdc_FILE="\"main.cpp\"" --define=UARTLOG_NUM_EVT_BUF=32 -g --c99 --gcc --diag_warning=225 --diag_warning=255 --diag_wrap=off --display_error_number --gen_func_subsections=on --abi=eabi --preproc_with_compile --preproc_dependency="Startup/main.d" --obj_directory="Startup" --cmd_file="configPkg/compiler.opt" "../Startup/main.cpp"

>> Compilation failure
Startup/subdir_rules.mk:16: recipe for target 'Startup/main.obj' failed
"c:/ti/simplelink/ble_sdk_2_02_01_18/src/components/icall/src/inc/icall.h", line 449: error #80: expected a type specifier
"c:/ti/simplelink/ble_sdk_2_02_01_18/src/components/icall/src/inc/icall.h", line 449: error #91: function returning function is not allowed
"c:/ti/simplelink/ble_sdk_2_02_01_18/src/components/icall/src/inc/icall.h", line 826: error #20: identifier "ICall_MsgMatchFn" is undefined
"c:/ti/simplelink/ble_sdk_2_02_01_18/src/components/icall/src/inc/icall.h", line 2285: error #91: function returning function is not allowed
"c:/ti/simplelink/ble_sdk_2_02_01_18/src/components/icall/src/inc/icall.h", line 2289: error #302: a pointer to a bound function may only be used to call the function
"c:/ti/simplelink/ble_sdk_2_02_01_18/src/components/icall/src/inc/icall.h", line 2291: error #302: a pointer to a bound function may only be used to call the function
"c:/ti/simplelink/ble_sdk_2_02_01_18/src/components/icall/src/inc/icall.h", line 2365: error #91: function returning function is not allowed
"c:/ti/simplelink/ble_sdk_2_02_01_18/src/components/icall/src/inc/icall.h", line 2370: error #302: a pointer to a bound function may only be used to call the function
"c:/ti/simplelink/ble_sdk_2_02_01_18/src/components/icall/src/inc/icall.h", line 2638: error #20: identifier "ICall_MsgMatchFn" is undefined
"c:/ti/tirtos_cc13xx_cc26xx_2_20_01_08/products/cc26xxware_2_24_02_17393/driverlib/interrupt.h", line 137: error #91: function returning function is not allowed
"c:/ti/tirtos_cc13xx_cc26xx_2_20_01_08/products/cc26xxware_2_24_02_17393/driverlib/interrupt.h", line 159: error #91: function returning function is not allowed
"c:/ti/tirtos_cc13xx_cc26xx_2_20_01_08/products/cc26xxware_2_24_02_17393/driverlib/interrupt.h", line 366: error #91: function returning function is not allowed
12 errors detected in the compilation of "../Startup/main.cpp".
gmake: *** [Startup/main.obj] Error 1
gmake: Target 'all' not remade because of errors.

**** Build Finished ****

  • It looks like the problem is coming from _hal_types.h. Line 68 defines bool as _Bool but isn't protected from the c++ compiler so it redefines bool and destroys everything.

    If you wrap the #define with cplusplus guards then everything is OK:

    #ifndef __cplusplus
    #define bool _Bool
    #endif

    The file is installed at:
    C:\ti\simplelink\ble_sdk_2_02_01_18\src\components\hal\src\target\_common\cc26xx\_hal_types.h

    TI, PLEASE FIX THIS IN YOUR LIBRARIES!
  • Hi Kevin,

    Thank you for the notification. I have forwarded to our stack developers.

    Cheers,
    Fredrik