cancel
Showing results for 
Search instead for 
Did you mean: 

How to exclude a single file from being build with a specific compiler/language in STM32CubeIDE?

MGuth.1
Associate III

I'm having trouble compiling a TouchGFX project in STM32CubeIDE.

As I need to call a C++ function (touchgfx::OSWrappers::signalVSync()) from inside a .c file (app_azure_rtos.c) I created a C++-linker function as described in this thread.

Also as described in aboves thread I'm getting an error when compiling. The Error says

../Middlewares/ST/touchgfx/framework/include/touchgfx/hal/OSWrappers.hpp:23:1: error: unknown type name 'namespace'
   23 | namespace touchgfx

So it seems that the C-Compiler tries to compile a .hpp header file.

How can I tell the C-Compiler to exclude a single file from being build? I can exclude a whole directory . But this makes the whole directory (all files included) unavailable for all compilers/languages. I'm on STM32CubeIDE 1.12.0

11 REPLIES 11
MGuth.1
Associate III

Found the mistake:

I was still including the OsWrappers.hpp inside a C file. This caused the C linkage fault.

By the way, in *.cpp files the #ifdef __cplusplus is completely useless and the extern "C" is also not necessary as the function is already declared as such in a header file.