1

I have a working uVision 5.13 project for the STM32F407 processor, I'm also using the RTX operating system and I'm trying to use some C++11 features like scoped enums but when I put the --cpp11 compiler option I receive this error from one of the cmsis headers:

compiling RTX_Conf_CM.c...
C:\Keil\ARM\PACK\ARM\CMSIS\4.2.0\CMSIS_RTX\INC\RTX_CM_lib.h(250): error: #390: function "main" may not be called or have its address taken osThreadDef_t os_thread_def_main = {(os_pthread)main, osPriorityNormal, 1, 4*OS_MAINSTKSIZE };
RTE\CMSIS\RTX_Conf_CM.c: 0 warnings, 1 error**

That´s compiling the same sources that was working just fine without the --cpp11 option.

Then if I add one of the supported C++11 features like this:

namespace TestNamespace
{

enum class Test : std::int16_t
{
  TestValue1 = 0
};

class TestClass
{

//All the class code here

};
}

then I start to receive messages from windows that "The ARM C/C++ Compiler has stopped working" every time the header file containing the scoped enum is compiled. This is the problem signature in windows:

Problem Event Name: APPCRASH
Application Name: ArmCC.exe
Application Version: 5.5.0.106
Application Timestamp: 547650a9
Fault Module Name: ArmCC.exe
Fault Module Version: 5.5.0.106
Fault Module Timestamp: 547650a9
Exception Code: c0000005
Exception Offset: 003f566a
OS Version: 6.1.7601.2.1.0.256.1
Locale ID: 1033
Additional Information 1: 0a9e
Additional Information 2: 0a9e372d3b4ad19135b953a78882e789
Additional Information 3: 0a9e
Additional Information 4: 0a9e372d3b4ad19135b953a78882e789

So, I'm doing something wrong or those are ARMCC bugs??

My uVision version is 5.13 and the compiler version is 5.05 update 1 build 106.

Praetorian
  • 106,671
  • 19
  • 240
  • 328
jcgalveza
  • 371
  • 5
  • 13

4 Answers4

2

The first error is absolutely correct, even in C++98 the practice was banned.

The compiler crash however is a ARMCC bug, regardless of your code. Even if you tried to compile an .mp3 file, it shouldn't crash.

MSalters
  • 173,980
  • 10
  • 155
  • 350
  • Thanks for your answer, I've posted the answer I received from ARM about both issues. I hope they will fix these two problems in the near future. – jcgalveza Jan 07 '15 at 17:33
1

For posterity, I've filed a bug with ARM and they told me this:

The internal fault is cause by a known issue to do with having scoped enums, and browse information selected (--omf_browse command line option, Output->Browse Information in the gui).

The fact the CMSIS-RTOS kernel does not compile with --cpp11 I shall raise with the technical team as a fault.

I suppose they will fix both problems in future versions.

jcgalveza
  • 371
  • 5
  • 13
0

Did you said --cpp11 in "Misc Controls" of c/c++ page?

You said cpp11 mode to all files. To .cpp and to .c

try test.c with --cpp11:

//an C file: test.c
#ifdef __cplusplus
#error c++ mode
#endif

or see to *.obj for mangled symbols

OPA
  • 1
  • 1
0

So, it is two and a half years later and they still haven't fixed it?

So there a two things one has to do it seems.

I re-factored my program into:

int main(void){
    main_rtx();
}

then in RTX_CM_lib.h, I changed line 414 to

extern int main_rtx(void);

That fixed the "address of error"

Then there are four extern "C"declarations one has to do on lines 72-76:

extern "C" OS_TID rt_tsl_self(void);
extern "C" void rt_mut_init(OS_ID mutex);
extern "C" OS_RESULT rt_mut_relase(OS_ID mutex);
extern "C" OS_RESULT rt_mut_wait(OS_ID mutex, int16_t timeout);

as well as on line 215

extern "C" void osTimerThread(void const *argument);

There may be more, but odds are that if you have a linker error about unresolved symbols, it is due to a missing "C" in the extern declarations.

This is hack fix, just for me to test C11 with exceptions on the STM32F746. I would rather put in a

#ifdef __cplusplus
   extern "C" {
#endif

    //external declarations

#ifdef __cplusplus
    } //extern "C"
#endif

around all the external declarations.

NB. int main_rtx(void) must be declared with cpp linkage, i.e. not within an extern "C" group.

Flip
  • 881
  • 7
  • 13