Skip to content

Commit d0c574c

Browse files
committed
single header include and compile flag for http
the example http_client.cpp shows to include the headers in following order: ``` ``` 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: ``` ``` 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.
1 parent b4ad632 commit d0c574c

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

examples/http_client.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
#define NETLIB_USE_HTTP
2+
13
#include "../src/netlib.hpp"
2-
#include "../src/http/client.hpp"
3-
#include "../src/http/http.hpp"
44
#include <csignal>
55
#include <iomanip>
66
#include <iostream>

src/netlib.hpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,8 @@
22

33
#include "client.hpp"
44
#include "server.hpp"
5-
#include "thread_pool.hpp"
5+
#include "thread_pool.hpp"
6+
7+
#ifdef NETLIB_USE_HTTP
8+
#include "http/client.hpp"
9+
#endif

0 commit comments

Comments
 (0)