Skip to content

Conversation

@maj0ran
Copy link

@maj0ran maj0ran commented Aug 10, 2023

the example http_client.cpp shows to include the headers in following order:

#define "../src/netlib.hpp"
#define  "../src/http/client.hpp"
#define "../src/http/http.hpp"

However, a common setting in auto-formatters like clang-format will sort the headers in alphabetical order (which is also a requirement in some code-styles), like this:

#define  "../src/http/client.hpp"
#define "../src/http/http.hpp"
#define "../src/netlib.hpp"

But this will lead to compilation errors as netlib.hpp includes headers that are needed by client.hpp, for example <future> but also library-defined symbols like DEFAULT_TIMEOUT or TICK_TIME, which are then included or defined after client.hpp needs them.

The ordering of includes of all needed library-headers should not matter, but a single header file to include everything would be preferable anyway. To exclude features like HTTP by default anyway, a compile switch is added.

the example http_client.cpp shows to include the headers in following
order:

```
"../src/netlib.hpp"
"../src/http/client.hpp"
"../src/http/http.hpp"
```

However, a common setting in auto-formatters like clang-format will sort
the headers in alphabetical order (which is also a requirement in some
code-styles), like this:

```
"../src/http/client.hpp"
"../src/http/http.hpp"
"../src/netlib.hpp"
```

But this will lead to compilation errors as `netlib.hpp` includes
headers that are needed by `client.hpp`, for example  `<future>` but
also library-defined symbols like `DEFAULT_TIMEOUT` or `TICK_TIME`,
which are then included or defined after `client.hpp` needs them.

The ordering of includes of all needed library-headers should not
matter, but a single header file to include everything would be
preferable anyway. To exclude features like HTTP by default anyway, a
compile switch is added.
@maj0ran maj0ran force-pushed the single_header_include branch from d0c574c to 7b37e42 Compare August 11, 2023 06:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant