summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Friedt <cfriedt@meta.com>2022-11-22 06:20:37 -0500
committerJens Geyer <Jens-G@users.noreply.github.com>2022-11-22 21:56:29 +0100
commit850c61f6086f3a373de8c588c5b25d0ba37c3618 (patch)
tree0a63f7b6f6ecf8663342aad96eb48668b05469dc
parent779deabf0e1fdefe4f6340546181ac9d81fcf670 (diff)
downloadthrift-850c61f6086f3a373de8c588c5b25d0ba37c3618.tar.gz
lib: cpp: transport: include thrift/config.h in TFDTransport
The `PlatformSocket.h` defines some macros that reference symbols in the libc without including the necessary headers. Moreover, the headers are protected by config macros (i.e. `#ifdef HAVE_UNISTD_H`). This makes header ordering rather fragile. Explicitly include `<thrift/config.h>` and conditionally include `<unistd.h>` prior to referencing them. A future improvement to reduce fragility would be to add includes directly in `PlatformSocket.h`. Signed-off-by: Chris Friedt <cfriedt@meta.com>
-rw-r--r--lib/cpp/src/thrift/transport/TFDTransport.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/lib/cpp/src/thrift/transport/TFDTransport.cpp b/lib/cpp/src/thrift/transport/TFDTransport.cpp
index 4e28c318b..80429dbb7 100644
--- a/lib/cpp/src/thrift/transport/TFDTransport.cpp
+++ b/lib/cpp/src/thrift/transport/TFDTransport.cpp
@@ -20,16 +20,18 @@
#include <cerrno>
#include <exception>
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
#ifdef _WIN32
#include <io.h>
#endif
-#include <thrift/transport/TFDTransport.h>
+#include <thrift/config.h>
+
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
#include <thrift/transport/PlatformSocket.h>
+#include <thrift/transport/TFDTransport.h>
using std::string;