Search code examples
c++brew-frameworkbrewmp

What parts of C++ are / aren't supported with Brew (MP)?


Hi I'm trying to find out what is and isn't possible with C++ on BrewMP.

Does anybody have first hand experience of using C++ with Brew, specifically BrewMP, and can say if they have managed to get these things working on a device without too much hassle:

  • static variables/functions
  • templates
  • exceptions
  • casting etc.

Solution

    1. Before in Brew3.X, global and static variables are not supported. However in Brew MP, there is an ELF2MOD tool. With this, you can use global and static varaibles.
      See your SDK path such as:
      C:\Program Files\Qualcomm\Brew MP SDK\Toolset 7.10 Rev 10.0.1489821\bin

      If your global or static data is non-POD (a C++ object, which has to call C++ class constructor), please don't use it. See https://developer.brewmp.com/forum/using-static-variables-classes-0

    2. Standard C Library (stdc lib, or c runtime) are absolutely prohibited in BrewMP, such as memset and sprintf. Cause: In a general process module with main() entry, those of C runtime are already initialized automatically before user's code calling them. BrewMP mod (mod1) files are dynamically loaded and linked. There are no appropriate time to call initialization, and these MODs should not call C runtime initialization individually.

    3. C++ template functions and template classes: template code instantiation are generted at compile-time, and they don't need any load-time and run-time code initialization. They can be used safely in device.

    4. C++ Exceptions: I didn't tested it. In the default ARM compiler options, exception are not turned on. And the exceptions need the enablement of C++ RTTI.

    5. C++ cast: dynamic_cast is the big problem, because it needs support run-time type identification enabled, and doing type checking at run time. Other casts, such as static_cast, reinterpret_cast, and const_cast, are only a hint for compiler to check at compile-time.