I want to use STM32CubeMX and I would like to program my new project in C++. I am using the latest version of STM32CubeMX (4.21.0) and the latest version of Keil uVision (220.127.116.11).
After code generation I have added the compiler flag "--cpp". I haven't added any custom code yet. But when I compile the project I get the following error. Without the compiler flag everything compiles and links without an error or warning.
../Inc/adc.h(62): error: #337: linkage specification is incompatible with previous "_Error_Handler" (declared at line 162 of "../Inc/main.h")
extern void _Error_Handler(char *, int);
The function declarations for "_Error_Handler" seems to be correct. In main.c the function declaration is included from main.h and from every peripheral-header. In main.h the declaration does not have an "extern" specifier. That seems to be the only difference. When I remove the function declaration for "_Error_Handler" in main.h, it works.
But is that the correct way of programming in C++ with STM32CubeMX projects? If so, I would need to remove the declaration of "_Error_Hanlder" every time I re-generate the code.