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/CC3200: Write firmware in C and C++

Part Number: CC3200


Tool/software: Code Composer Studio

Hi there,

I'm starting to build up an SDK module that will be integrated in an existing firmware wrote in C.

This is my question: CanI develop the SDK in C++ language?

I never wrote firmware code in C++. I'm new to the use of C++ language in embedded systems.

Does Code Composer support the C++ code and it's compilation?

Does the adoption of C++ language may be create some problem? ( compile, linking, execution )

Thanks!

  • Sure, you can write it in C++, but why? Which features of C++ do you need in the firmware program? One problem with C++ in embedded software is that it can hide complexity. Once you start using C++ features like polymorphism, there's a lot of extra code and data produced by the compiler "under the hood," so you might not have a good sense of (for instance) code size when looking at C++ code. On the other hand, if you use C++ as if it were C with stricter type checking, you'll be fine.
  • Hi Archaeologist,

    thanks for the reply.

    I don't want to use C++ to develop my SDK, but my customer had wrote his firmware in C++ and his firmware will integrate my SDK. So my SDK must be write in C++ (this is customer requirements).

  • Is that really a requirement, or does the customer just want to be able to call your functions from C++ code? If the latter is the case, just make sure your header file detects when it is being included from C++ mode (defined(__cplusplus)) and wrap all of your declarations in extern "C"
  • Good question! I don't know the intention of my customer, but I will try to understand this in the next meeting. Thanks for the hint regarding the header file.
  • C++ is very powerful and it can improve your SDK's structure massively if and only if you use it correctly. Please check my blog for C++ features which can be used for embedded systems.

    If you are not familiar with C++ then you have two choices:
    1. Use C to design your SDK. Your customer can call your APIs without problem if you use "#ifdef__cplusplus ... " in your header files.
    2. Learn C++ and design the whole SDK by C++. This will take time, but you will find that your SDK becomes very easy to maintain and use.

    Personally, I design almost everything (excepting RTOS) in C++. My RTOS also supports C++ by defining a Task class.