Questions tagged [include]
The include tag has no usage guidance.
21
questions
2
votes
3
answers
161
views
Should I ensure my libfoo library's include file can be included as foo/foo.h?
I'm maintaining a small C library; let's call it libfoo. It has quite a few users (actually it's complicated - it's the main fork of a highly popular library which has been abandoned); and it sports a ...
4
votes
1
answer
720
views
The case against path expressions in #include directives
I am preparing for a discussion with my fellow programmers which will be about their use of the C/C++ #include directive. The codebase which I have to retrofit to Automotive standards is using ...
1
vote
1
answer
757
views
UML Use Case Diagrams Relationship - Required / Optional AND independent
I am learning to create Use Case diagrams using the UML specification, but I have a couple of doubts about Use Case relationships which I cannot solve on my own.
My question regards two different ...
4
votes
1
answer
126
views
Should I specify my header include path in the source code, or as a project option?
Basically, I am asking, whether my code should say
#include “../libs/src/my_lib.h”
or
#include “my_lib.h”
with a complier option of
-I ../libs/src/
I feel (reasonably strongly) that ...
3
votes
2
answers
2k
views
Include own header file first or last? Any technical reasons?
I was revisiting my question How can I prevent header hell?, when I noticed a comment which said
A good technique for ensuring a header is independent is having a rule that the source file always ...
4
votes
3
answers
3k
views
Detecting header inclusion chains and dependencies in C++
File Top.h
#include <string>
...some code...
File Bottom.h:
#include "Top.h"
void someFunction() {
string s = new String();
...
}
The Bottom.h does not contain an include for the string ...
0
votes
1
answer
520
views
UML, <<extending>> and <<including>> from the same use case
This is a use case diagram about the enrollment of students at a university. There are several flaws in it, and I have to find them.
I am wondering what is happening when you get to use case "Choose ...
2
votes
1
answer
698
views
Use case causes other use cases
I am making this independent drone control system that a user can start and stop. When the program is started, the connected drone takes off, hovers, and turns to face the other side. At first I ...
52
votes
7
answers
33k
views
How can I prevent header hell?
We are starting a new project, from scratch. About eight developers, a dozen or so subsystems, each with four or five source files.
What can we do to prevent “header hell”, AKA “spaghetti headers”?
...
5
votes
2
answers
8k
views
Is including headers inside a namespace always a bad idea?
The replies in this post come very strongly against including headers inside a namespace and Doxygen is confused if that is done (which suggests that its team did not consider that usage either). I ...
2
votes
2
answers
214
views
Fully Specifying #includes
I'm very fastidious about code. When I remove functionality from a file I remove the cooresponding #includes. I've hit several errors where I would remove a #include from a header, and another file ...
1
vote
4
answers
3k
views
cpp and h/hpp #include: "why" question
Why does the source include a header and not also the other way around? I googled it but only found questions regarding the use of header files, how to include them but nowhere to say why it is like ...
1
vote
1
answer
1k
views
When should I use a precondition and when to include another use-case to provide those conditions?
For example, suppose 'Borrwoing a book' a use case:
I can figure out two description for it:
Description one:
Precondition: The member to access this use-case should be already logged in.
OR EVEN ...
54
votes
8
answers
20k
views
Is it good practice to rely on headers being included transitively?
I'm cleaning up the includes in a C++ project I'm working on, and I keep wondering whether or not I should explicitly include all headers used directly in a particular file, or whether I should only ...
19
votes
7
answers
52k
views
Why do we need to include the .h while everything works when including only the .cpp file?
Why do we need to include both the .h and .cpp files while we can make it work solely by including the .cpp file?
For example: creating a file.h containing declarations, then creating a file.cpp ...
3
votes
1
answer
3k
views
Single complex or multiple simple autoload functions
Using the spl_autoload_register(), should I use a single autoload function that contains all the logic to determine where the include files are or should I break each include grouping into it's own ...
7
votes
1
answer
5k
views
When defining directory path, should a trailing slash be included?
Say I'm defining a directory and then including files from it. Is it better practice to do:
define('PATH', 'C:/xampp/htdocs/includes/');
require PATH.'header.php;
or:
define('PATH', 'C:/xampp/...
5
votes
5
answers
6k
views
Is it bad to place "include directive" within main function?
It is always said that the include directives should be placed at the beginning of a script. The main reason is to make the functions available throughout the script. Regardless of this fact, is it ...
11
votes
7
answers
5k
views
Ensuring that headers are explicitly included in CPP file
I think it's generally good practice to #include the header for any types used in a CPP file, regardless of what is already included via the HPP file. So I might #include <string> in both my HPP ...
3
votes
1
answer
221
views
Handling bugs, quirks, or annoyances in vendor-supplied headers
If the header file supplied by a vendor of something with whom one's code must interact is deficient in some way, in what cases is it better to:
Work around the header's deficiencies in the main code
...
4
votes
1
answer
1k
views
Including local headers first
So I read up on the ordering of your includes, and this guy suggested you include your local header first so as to make sure it doesn't have prerequisites. Ok, I get that. I'm on board. The whole ...