Author Topic: Question about code::blocks update new practice.  (Read 9598 times)

Offline James

  • Single posting newcomer
  • *
  • Posts: 2
Question about code::blocks update new practice.
« 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

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"
just gets a compile error saying that it is not found.  I tried using
Code
#include "..\include\class.h"
but it does not work either.  This part may be a little to "General Coding" ish, but my questions are justified I think.

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3352
Re: Question about code::blocks update new practice.
« Reply #1 on: July 23, 2013, 04:09:53 pm »
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"
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

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3352
Re: Question about code::blocks update new practice.
« Reply #2 on: July 23, 2013, 06:35:53 pm »

Offline James

  • Single posting newcomer
  • *
  • Posts: 2
Re: Question about code::blocks update new practice.
« Reply #3 on: July 23, 2013, 11:01:17 pm »
Wow this is annoying... so I have to use
Code
#include "include/class.h"
in my main class, but in my other classes, I have to use
Code
#include "../include/class.h"
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?

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7252
Re: Question about code::blocks update new practice.
« Reply #4 on: July 23, 2013, 11:10:40 pm »
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.

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
You can  change this in the dialog while creating the new files with the wizard.