Skip to main content
43 votes
Accepted

How can I prevent header hell?

Simple method: One header per source file. If you have a complete subsystem where users are not expected to know about the source files, have one header for the subsystem including all required header ...
gnasher729's user avatar
  • 45.8k
20 votes

How can I prevent header hell?

By far the most important requirement is to reduce dependencies between your source files. In C++, it is common to use one source file and one header per class. Therefore, if you have a good class ...
Frank Puffer's user avatar
  • 6,429
14 votes

How can I prevent header hell?

In addition to the other recommendations, along the lines of reducing dependencies (mainly applicable to C++): Only include what you really need, where you need it (lowest level possible). E. g. don'...
Murphy's user avatar
  • 821
9 votes

The case against path expressions in #include directives

I think the key issue here is a clear and consistent project structure and good names. An unstructured monolith with twelve different blue.h files in different directories at different depths in the ...
besc's user avatar
  • 1,163
9 votes

Should I specify my header include path in the source code, or as a project option?

In my current workplace, various projects are using boost versions ranging from 1.60 to 1.66, and at appropriate times we move those forward. It's much simpler to repoint the project includes to a ...
Caleth's user avatar
  • 11.4k
8 votes
Accepted

Detecting header inclusion chains and dependencies in C++

This is a common but unsolvable problem with C++. A header provides some declarations. How the header provides these declarations is an implementation detail, and it is completely valid if the header ...
amon's user avatar
  • 135k
8 votes
Accepted

Include own header file first or last? Any technical reasons?

#include directives are processed in the order in which they are encountered in the sources. Conceptually, when a #include is encountered, that directive is replaced with the content of the referenced ...
Bart van Ingen Schenau's user avatar
8 votes

How can I prevent header hell?

One header per source file, which defines what its source file implements/exports. As many header files as necessary, included in each source file (starting with its own header). Avoid including (...
ChrisW's user avatar
  • 3,417
7 votes

Should I ensure my libfoo library's include file can be included as foo/foo.h?

Picking out some reasonably well known C libraries: Expat uses #include <expat.h> Glib uses #include <glib.h> Jansson uses #include <jansson.h> SQLite uses #include <sqlite3.h>...
Philip Kendall's user avatar
5 votes
Accepted

UML Use Case Diagrams Relationship - Required / Optional AND independent

Use-cases are not intended to have any sequencing between them. Use-cases are meant to represent interactions with the system that are of value for the actors (i.e. use cases correspond to goals ...
Christophe's user avatar
  • 78.3k
4 votes

Should I ensure my libfoo library's include file can be included as foo/foo.h?

There are two reasons for using an additional subdirectory for include files: Avoiding potential naming collisions You want to be prepared for the case when the lib may offer more than one include ...
Doc Brown's user avatar
  • 209k
4 votes

Include own header file first or last? Any technical reasons?

There are two options for header structure I have seen used: Headers do not include headers. This approach has the advantage that headers are light, and you don't get lots of needless multi-inclusion ...
Jack Aidley's user avatar
  • 2,952
3 votes

How can I prevent header hell?

I would claim your question is fundamentally unanswerable, since there are two kinds of header hell: The kind where you need to include a million different headers, and who in hell can even remember ...
einpoklum's user avatar
  • 2,538
3 votes

Should I ensure my libfoo library's include file can be included as foo/foo.h?

Given your recent comment: But I suspect that in my specific case it's because glibc has a non-standard header file with the same name as mine (printf.h). I'd think including your header as #include ...
Andrew Henle's user avatar
2 votes

Detecting header inclusion chains and dependencies in C++

A rule that you should follow in languages like C, C++, Objective-C is that every single header file compiles on its own. This is achieved here (so someone including bottom.h doesn’t need to remember ...
gnasher729's user avatar
  • 45.8k
2 votes

Is including headers inside a namespace always a bad idea?

As a general rule, I would never include a file within a namespace for the reasons dan1111 gives in his answer. If the purpose of your header is to share code, you are forcing users of your code to ...
Marc's user avatar
  • 121
2 votes

Is it good practice to rely on headers being included transitively?

There can be another case: You have A.h, B.h and your C.cpp, B.h includes A.h so in C.cpp, you can write #include "B.h" #include "A.h" // < this can be optional as B.h already has all the stuff ...
bugs king's user avatar
  • 193
2 votes
Accepted

Use case causes other use cases

Your use case seems correct Each use case of the system under consideration (your drone system) is: the description of a set of sequences of actions and variants that a system performs that ...
Christophe's user avatar
  • 78.3k
1 vote

Detecting header inclusion chains and dependencies in C++

Starting in Visual Studio 17.8 Preview 1, there's an #include cleanup feature that does what you are looking for. It finds #includes that you are using but aren't explicitly #including and adds them ...
Tyler Whitney's user avatar
1 vote

Detecting header inclusion chains and dependencies in C++

Use unit tests. You arrange your unit test code so that each unit test/suite runs in a separate translation unit. This will mean that each header gets pulled and trialled in one or more alternative ...
Benedict's user avatar
  • 1,097
1 vote

UML, <<extending>> and <<including>> from the same use case

I am not really sure to understand your use case diagram. What do you want to express? I guess that a Student can "Enroll a Course". To do so, he needs to "Pay fees", "Choose ...
Red Beard's user avatar
  • 191

Only top scored, non community-wiki answers of a minimum length are eligible