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>
diff --git a/lib/cpp/src/thrift/transport/TFDTransport.cpp b/lib/cpp/src/thrift/transport/TFDTransport.cpp
index 4e28c31..80429db 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;