User forums > Help
Question about code::blocks update new practice.
(1/1)
James:
I recently just installed Code::Blocks on my new Windows Blue testing OS and noticed that when creating a new class, it stores the class in /scr/class.cpp and the header file in /include/class.h
Is this a c++ standard practice? Or is it something that Code::Blocks just does?
I know how to change it, but if it's standard coding practice, I would like to learn how to deal with this.
My problem is that by default the
--- Code: ---#include "class.h"
--- End code ---
just gets a compile error saying that it is not found. I tried using
--- Code: ---#include "..\include\class.h"
--- End code ---
but it does not work either. This part may be a little to "General Coding" ish, but my questions are justified I think.
BlueHazzard:
i don't think that it exists a standard for this...
it's a "nice to do" rule for a ordered code path structure...
The problem with the "not found" error is annoying, that's true. The proper solution would be
--- Code: ---#include "include/class.h"
--- End code ---
because the base include directory is your project directory, so if you use "../include/class.h" you would go one directory to high.
or to add the include directory in Project->Build Options->search directories->compiler.
I think this should be done automatically (or at least optional with default on) from the "Add class" function... If I have time I will look into it...
greetings
BlueHazzard:
created a patch to add the path automatically:
http://developer.berlios.de/patch/index.php?func=detailpatch&patch_id=3488&group_id=5358
greetings
James:
Wow this is annoying... so I have to use
--- Code: ---#include "include/class.h"
--- End code ---
in my main class, but in my other classes, I have to use
--- Code: ---#include "../include/class.h"
--- End code ---
instead..
Well here's something that the Code::Blocks team could add to their to-do list, automatically fill in the directory with the correct path.. Hmm..
Does anyone else think that this is tedious to use different include code for classes in the main directory, in other directories, and having to change it to include the /include/ directory?
Thanks for the help though!
Also is it practice to store classes in the /src/ directory and headder files in the /include/ directory?
Jenna:
You should not use the include statement with just the headerfilename and add the path to the projects or targets compiler search dirs, so the include-stement is the same in all files.
Adding this automatically (if this option is not explicitely unchecked by the user) is (in my opinion) the brdt way.
--- Quote from: James on July 23, 2013, 03:36:38 pm ---I recently just installed Code::Blocks on my new Windows Blue testing OS and noticed that when creating a new class, it stores the class in /scr/class.cpp and the header file in /include/class.h
--- End quote ---
You can change this in the dialog while creating the new files with the wizard.
Navigation
[0] Message Index
Go to full version