cancel
Showing results for 
Search instead for 
Did you mean: 

Including external header files in project

mpent
Associate

I have used cube ide for a short while, and have written (in C) some header files for different sensors and whatnot. I have a folder that gathers all these headers on my pc. In cube ide i have been referencing these headers such that i did not copy them directly into my project but kept them in the original header folder. This is useful for me when i work on different project that uses the same header and I make a correction in one of the projects then I have the most updated version in all the other projects as well.

However, i tried VSCode and the stm32 extension but cannot get referencing the headers correct. My projects work fine in vs code if i copy the headers directly in the project folder but i would like to avoid this to prevent different versions of the same header.

Unfortunately I did not find any way ro reference the header files in a similar way i did with cube ide. I also tried the new version of visual studio as it also got support for stm32 embedded development but i have the same isssue.

Is it possible to do this in either visual studio or is it just an eclipse specific function?

1 REPLY 1
ZDima
Associate II

Hi

My work around to this problem is to add include path in the CMakeLists.txt after target is configured:

 

add_st_target_properties(${PROJECT_NAME})

target_include_directories(
    ${PROJECT_NAME} PRIVATE
    "$<$<AND:$<CONFIG:Debug>,$<COMPILE_LANGUAGE:C>>:${PROJECT_SOURCE_DIR}/App/Inc>"
)

 

 
😀