Code::Blocks Forums
User forums => General (but related to Code::Blocks) => Topic started by: AZ on August 17, 2020, 08:54:02 pm
-
hello,
what is the proper syntax to include a lib's h file:
a. #include "../path/to/file.h"
b. #include "file.h"
platformio specifies a full path to library/src for all libs used in the project and, as such, all i should type is "file.h".
-
.h means it is an header file! It is not an library file!
a. #include "../path/to/file.h"
b. #include "file.h"
b is better than a in my opinion
Tim S.
-
.h means it is an header file! It is not an library file!
a. #include "../path/to/file.h"
b. #include "file.h"
b is better than a in my opinion
Tim S.
Tim,
the correction is well taken. I updated the thread accordingly.
to go with "b", what do i need to configure in CB? by default, it is throwing "file not found" during the compilation. For simplicity, lets say i have the following project structure:
proj name
- src
main.cpp
- lib
library_name
lib.h
- include
-
http://wiki.codeblocks.org/index.php/FAQ-Compiling_(general)#Q:_I_would_like_to_compile_a_project_using_some_non-standard_libraries._How_can_I_indicate_to_CodeBlocks_that_these_libraries_and_include_files_exist.3F (http://wiki.codeblocks.org/index.php/FAQ-Compiling_(general)#Q:_I_would_like_to_compile_a_project_using_some_non-standard_libraries._How_can_I_indicate_to_CodeBlocks_that_these_libraries_and_include_files_exist.3F)
Do not use the "For global environment" section.
Do use the "For your project" section.
Edit: Including headers are compiler options.
Tim S.
-
That is exactly how i went about it https://imgur.com/XqHqg7W.png
though it is odd that the directories are not been propagated into targets: https://imgur.com/CAToKGc.png
yet I added the directory to both targets. CB still doesn't show them in the autocomplete:
https://imgur.com/xBiAi4d.png
Aha, Bingo! to have the autocomplete to work properly:
0. follow the link Tim suggested above.
1. in the "search directories" (project level, not "target") specify path _to_ the H/HPP files.
2. "save" the project. "reparse" the project.
3. HPP files do not get into autocompletion for "include", but they are parsed, so the code autocomplete uses the classes from them.
Thank you Tim!