Hi,
I used PCLint to check my code yesterday and got some warnings about
"Repeated include files" and "Redundant declaration for symbol
'CLASSNAME'". I know the reasons for these warnings and I think they are
not a problem. But all this made me think about the order in which
header files are include.
Think about a 4 layered architecture with
layer GUI (contains GUI_A,h, ...)
layer APP (contains APP_A.h, ...)
layer CORE (contains CORE_A.h, CORE_B.h, CORE_C.h ... you get it)
layer STL (contains vector, set, ...)
and a top-bottom dependency.
Now let's say class GUI_A needs APP_A.h, CORE_A.h, and vector to be
included in it's header. What would be the correct order to include it?
Starting at the bottom or at the top?
And further, class GUI_A needs GUI_A.h, APP_B.h, CORE_B.h and set in
it's source to compile. Should this be in the same order as in the
header file?
Does the standard say something about it? Or are the any guidelines for
this?
Thanks in advance,
Marco 1 1728
"Marco Spatz" <ma******@web.de> skrev i meddelandet
news:5v************@icido.de... Hi,
I used PCLint to check my code yesterday and got some warnings about "Repeated include files" and "Redundant declaration for symbol 'CLASSNAME'". I know the reasons for these warnings and I think they are not a problem. But all this made me think about the order in which header files are include.
Think about a 4 layered architecture with
layer GUI (contains GUI_A,h, ...)
layer APP (contains APP_A.h, ...)
layer CORE (contains CORE_A.h, CORE_B.h, CORE_C.h ... you get it)
layer STL (contains vector, set, ...)
and a top-bottom dependency.
Now let's say class GUI_A needs APP_A.h, CORE_A.h, and vector to be included in it's header. What would be the correct order to include it? Starting at the bottom or at the top?
It shouldn't matter. :-)
And further, class GUI_A needs GUI_A.h, APP_B.h, CORE_B.h and set in it's source to compile. Should this be in the same order as in the header file?
Does the standard say something about it? Or are the any guidelines for this?
The guideline is that each header should include everything it needs.
You can use include guards #ifdef ... #endif in the headers, to avoid
defining the same symbol more than once.
Bo Persson This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: qazmlp |
last post by:
I need to include a list of
- C++ headers
- headers of other modules
- headers of my module
- implementation specific ie.OS headers
In what order, they should be included in my .CPP file?...
|
by: header_question |
last post by:
Is it best to place all #include files in one header file seperate
from all the other files in a project?
What is the logic that determines the order of the #include files,
does it depend on the...
|
by: Steven T. Hatton |
last post by:
In the past there have been lengthy discussiions regarding the role of
header files in C++. People have been very adamat about header files
serving as in interface to the implementation. I do...
|
by: pooja |
last post by:
Suppose i have created a class c1 with f1()in c1.cpp
and included this c1.cpp in file1.cpp file , which is also having
main() by giving the statement #include "c1.cpp".
the same i can do by...
|
by: Derrick Coetzee |
last post by:
It seems like, in every C source file I've ever seen, there has been a
very definite include order, as follows:
- include system headers
- include application headers
- include the header...
|
by: nrhayyal |
last post by:
Hi c++ Gurus,
Need your blessing.
while testing few aspects with respect to header file inclusions, i
observed few things which i would like to share with you.
i have a file sqlca.h in which a...
|
by: fc2004 |
last post by:
Hi,
Is there any tools that could report where cyclic header dependency
happens? this would be useful when working with a large project where
tens or hundreds of headers files may form complex...
|
by: Ben |
last post by:
I'm kind of new to creating templates. I've made some small class and
function templates in the past and I have used quite of bit of the STL,
but I am having problems tyring to create templates.
...
|
by: Gary Wessle |
last post by:
Hi
is it right to have a line like
#include <path/to/header.hfor a library on my system, in my header
file and use some functions provided by this library in the
implementation file (file.cpp)...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| |