main.h file not found in project dir unless full Windows path is provided

This is likely a Visual Studio issue but figured this is an obvious rookie error so someone will set me straight right away! I have loaded a sample project and compiled and run it properly on my hardware development kit; I can debug and all is good. However, the 'main.c' file that was provided contains a lot of stuff that I would normally expect to see in a 'main.h' file (which wasn't included as part of the sample). I created the main.h file and added it to the same folder as main.c and the intelisense cannot find it if I use "#include <main.h>". However, if I instead include the entire Windows directory path with the file name, then it works OK. How is the system not seeing the file since it is clearly in the project directory?

Parents
  • Hi Paul,

    Two paths forward:

    1) you can use #include "main.h"

    2) you can use #include <main.h> if the path for that file is included in CMakeLists.txt by adding it as an include path.

    For instance, if main.h is in the same location as main.c in your_project/src, then adding zephyr_include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src) before the project sources will work. 

    Best regards,

Reply
  • Hi Paul,

    Two paths forward:

    1) you can use #include "main.h"

    2) you can use #include <main.h> if the path for that file is included in CMakeLists.txt by adding it as an include path.

    For instance, if main.h is in the same location as main.c in your_project/src, then adding zephyr_include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src) before the project sources will work. 

    Best regards,

Children
Related