User forums > Using Code::Blocks

Path of headerfile

(1/2) > >>

Gerd:
When adding a class to a cpp project I get a headerfile in my include folder and the cpp file in the scr folder, but #include "headername.h" which is automatically included in the cpp file, is not found.

This can be avoided by using #include "../include/headername.h" but I wounder why this is.
Why does codeblocks by default add a include line that does not work (neither in windows nor linux)

People keep telling me it's a Bug but I would like to get an answer from those who know for sure.

Thank you for any help

oBFusCATed:

--- Quote from: Gerd on May 09, 2013, 04:03:23 am ---People keep telling me it's a Bug but I would like to get an answer from those who know for sure.

--- End quote ---
I'm not sure if it is a bug.
But just add "include" in your Project->Build options->Search dirs -> Compiler and it will work.

Jenna:
I think it would be usefule to make it configurable to explicitely add the include path to the current projects include paths.
But where to place it ?
In the classwizard-dialog or as question after creating it, just like the add to current project question ?

As we have the dialog, that asks whether the newly created class-files should be added to the current project or not, it would make more sense to have an extra dialog for it, but it would be another extra click.

By the way wouldn't it make sense to make it possible to add the class (and the includes) on target-level and not onnly on project-level like it is done now ?

scarphin:
It's not a bug. 'gcc' looks for the include'd file in the folder of the file including it by default so it cannot find the 'include' folder obviously. Using '-iquote' includes the corresponding path to the search directories for quote style includes like "someheader.h". So add the following to your 'project-> build options-> compiler settings-> other options'.

--- Code: ----iquote $(PROJECT_DIR)
--- End code ---

Gerd:
Thank you for the comment.

I'm just wondering why this is a default behaviour.
Wouldn't it make sense to add -iquote $(PROJECT_DIR) by default?

Navigation

[0] Message Index

[#] Next page

Go to full version