Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [include]

The tag has no usage guidance.

4
votes
1answer
117 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
2answers
405 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 ...
1
vote
3answers
220 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 ...
1
vote
1answer
213 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
1answer
180 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 ...
44
votes
7answers
15k 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”? ...
1
vote
2answers
3k 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
2answers
197 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
4answers
2k 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
1answer
729 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 ...
36
votes
8answers
12k 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 ...
18
votes
7answers
39k 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
1answer
2k 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
1answer
3k 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
5answers
3k 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 ...
8
votes
7answers
4k 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
1answer
209 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 ...
3
votes
1answer
966 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 ...