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.

SIMPLELINK-CC13XX-CC26XX-SDK: Including headers from the C++ standard template library causes compilation errors

Part Number: SIMPLELINK-CC13XX-CC26XX-SDK
Other Parts Discussed in Thread: CC2652R7

Hello,

I am currently developing on the CC26x2R7 Launchpad and I am using IAR for ARM 8.50.9 and SDK 5.10.00.48. When working out of any project that uses TI's simplelink SDK, I am getting compilation errors when including certain headers (e.g. array.h) in my C++ files. For example, starting from the gpiointerrupt_LP_CC2652R7_tirtos_iar project, I've done the following:

  1. Renamed main_tirtos.c to main_tirtos.cpp
  2. Renamed gpiointerrupt.c to gpiointerrupt.cpp
  3. In main_tirtos.cpp, I added "#include <array>" where other header files are included:

/*
 *  ======== main_tirtos.cpp ========
 */
#include <stdint.h>

/* POSIX Header files */
#include <pthread.h>

/* RTOS header files */
#include <ti/sysbios/BIOS.h>

#include <ti/drivers/Board.h>
#include <array>

extern void *mainThread(void *arg0);

/* Stack size in bytes */
#define THREADSTACKSIZE    1024

/*
 *  ======== main ========
 */
int main(void)
{
    pthread_t           thread;
    pthread_attr_t      attrs;
    struct sched_param  priParam;
    int                 retc;

    Board_init();

    /* Initialize the attributes structure with default values */
    pthread_attr_init(&attrs);

    /* Set priority, detach state, and stack size attributes */
    priParam.sched_priority = 1;
    retc = pthread_attr_setschedparam(&attrs, &priParam);
    retc |= pthread_attr_setdetachstate(&attrs, PTHREAD_CREATE_DETACHED);
    retc |= pthread_attr_setstacksize(&attrs, THREADSTACKSIZE);
    if (retc != 0) {
        /* failed to set attributes */
        while (1) {}
    }

    retc = pthread_create(&thread, &attrs, mainThread, NULL);
    if (retc != 0) {
        /* pthread_create() failed */
        while (1) {}
    }

    BIOS_start();

    return (0);
}

Line 13 in the code snippet above causes compilation errors that seem to be completely unrelated to the array.h header:

These compilation errors only occur in TI's example projects. Just as a sanity check, I've created a new empty C++ project in IAR (so that nothing from the simplelink SDK is used), and I do not have compilation errors when i "#include <array>". I am able to use std::array functionality successfully.

So what in the TI simplelink SDK could be preventing me from being able to "#include <array>"?

Thanks,

Keron

  • Hi Keron,

    In main_tirtos.cpp, I added "#include <array>" where other header files are included:

    Does everything build/run ok if you don't do step 3?

    Thanks,
    Toby

  • Hi Toby,

    Yes the project builds with no issues if I don't do step 3. I only start getting compilation errors when I add:

    #include <array>

  • I think I have found the cause of my compilation errors. TI's projects have AEABI enabled in the  “Project options -> C/C++ Compiler -> Extra Options” tab. To get the code to compile I removed the following from the list of command line options:

    --aeabi

    According to the IAR C/C++ Developer Guide, "the AEABI does not specify C++ library compatibility", so this explains why I wasn't able to include any C++ headers. What are the implications of removing AEABI from my project? Will this result in larger code size or code that is less optimized in some way?

    Thanks,

    Keron

  • There may be risk of runtime errors, since the driver/stack libraries are built with --aeabi.

    I did a quick test for gpiostandby, removing the --aeabi option. The example still ran as expected.
    So, there is some possibility that the runtime risks would be minimal.

    In general, I'd recommend to code in C for these projects in IAR if that fits your application needs.

    For further IAR compiler related questions, I'd recommend reaching out to IAR, as they will likely be best suited to assist on those topics.