-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Correct stdc++ language and size issues for MSVC #8572
Changes from 14 commits
d5ba81c
5b5312d
7ea3522
3505e99
8172478
d62c39b
01da2c7
55a7360
bbf2f05
586fbbf
e5fb28d
5e98c83
ac0ee9e
94070c5
74cee40
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
diff --git a/include/tclap/StandardTraits.h b/include/tclap/StandardTraits.h | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you fix this one upstream? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We will submit it, but it is needed locally short term. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It seems small enough that we could kick this into the pipeline in parallel. We really dislike patches, they are only a solution when all else fails when working with an upstream project. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If and when we ever see a tclap 1.4 release, this patch and the defect go away, since the entire issue was refactored away 6 years ago; There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ack, please leave a reference to this thread in the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added short note + refactor link |
||
index 46d7f6f..117057b 100644 | ||
--- a/include/tclap/StandardTraits.h | ||
+++ b/include/tclap/StandardTraits.h | ||
@@ -123,8 +123,9 @@ struct ArgTraits<unsigned char> { | ||
typedef ValueLike ValueCategory; | ||
}; | ||
|
||
-// Microsoft implements size_t awkwardly. | ||
-#if defined(_MSC_VER) && defined(_M_X64) | ||
+// Microsoft implements size_t awkwardly. | ||
+// Studio 2005 introduces unsigned long long, which conflicts with the size_t template | ||
+#if defined(_MSC_VER) && (_MSC_VER < 1400) && defined(_M_X64) | ||
/** | ||
* size_ts have value-like semantics. | ||
*/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,64 @@ | ||
#pragma once | ||
|
||
// NOLINT(namespace-envoy) | ||
|
||
// This common "platform.h" header exists to simplify the most common references | ||
// to non-ANSI C/C++ headers, required on Windows, Posix, Linux, BSD etc, | ||
// and to provide substitute definitions when absolutely required. | ||
// | ||
// The goal is to eventually not require this file of envoy header declarations, | ||
// but limit the use of these architecture-specific types and declarations | ||
// to the corresponding .cc implementation files. | ||
|
||
#ifdef _MSC_VER | ||
|
||
#include <windows.h> | ||
#include <winsock2.h> | ||
|
||
// These must follow afterwards | ||
#include <mswsock.h> | ||
#include <ws2tcpip.h> | ||
|
||
// <windows.h> defines some frequently used symbols, so we need to undef these interfering symbols. | ||
#undef DELETE | ||
#undef ERROR | ||
#undef GetMessage | ||
#undef interface | ||
#undef TRUE | ||
|
||
#include <io.h> | ||
#include <stdint.h> | ||
|
||
#define PACKED_STRUCT(definition, ...) \ | ||
__pragma(pack(push, 1)) definition, ##__VA_ARGS__; \ | ||
__pragma(pack(pop)) | ||
|
||
#ifdef _M_X64 | ||
using ssize_t = int64_t; | ||
#else | ||
#error Envoy is not supported on 32-bit Windows | ||
using ssize_t = ptrdiff_t; | ||
|
||
typedef unsigned int sa_family_t; | ||
|
||
#else // POSIX | ||
|
||
#include <arpa/inet.h> | ||
#include <ifaddrs.h> | ||
#include <netdb.h> | ||
#include <netinet/in.h> | ||
#include <netinet/tcp.h> | ||
#include <sys/ioctl.h> | ||
#include <sys/mman.h> // for mode_t | ||
#include <sys/socket.h> | ||
#include <sys/uio.h> // for iovec | ||
#include <sys/un.h> | ||
#include <unistd.h> | ||
|
||
#if defined(__linux__) | ||
#include <linux/netfilter_ipv4.h> | ||
#endif | ||
|
||
#else | ||
#define PACKED_STRUCT(definition, ...) definition, ##__VA_ARGS__ __attribute__((packed)) | ||
|
||
#ifndef IP6T_SO_ORIGINAL_DST | ||
// From linux/netfilter_ipv6/ip6_tables.h | ||
#define IP6T_SO_ORIGINAL_DST 80 | ||
#endif | ||
|
||
#endif |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
#pragma once | ||
|
||
#include "envoy/common/platform.h" // Avert format.h including windows.h | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we fix There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As a practical matter? Any of our 3 dozen dependencies could introduce an #include <window.h> and disturb our source compilation, that header is not meant for general C++ language consumption. By this, we mean that MS heavily leverages #define and C++ heavily leverages multiple legible tokens. The logic in C language might introduce add_interface() but in C++ we are going to introduce interface.add(), which collides with windows.h defines. We've introduced platform.h to work around this every time we encounter the issue. And if it is fixed upstream, then we could drop our #include, but it isn't critical. The answer at envoy is to eventually stop using Posix or Windows types in our own .h interface definitions, and localize the Posix and Windows implementations to our .cc sources (which will always include platform.h.) Exceptions would include our .h interface stubs to third party libraries such as grpc, nghttp2, etc. I don't believe an upstream fix is really a priority, since I'm reading on #envoy-dev that fmtlib is being phased out for absl? It certainly shouldn't block this patch. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I feel that any 1st class support for Windows in Envoy doesn't end at Envoy. With my maintainer hat on I'm labeling this technical debt.. It's just a single line, but one day someone will come along and spend a day or so chasing down some obscure issue that is masked by this. At the same time, we're pragmatic about tech debt and want to see Windows support land. I would like to see tracking issues filed with the respective communities or in Envoy GH and referenced in these comments. Even if you folks aren't going to own this, we need to recognize these problems and provide the opportunity for other folks to do so. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, we will live with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Fair point, and researching, it turns out they have already responded. We have the option of disabling fmt.h's use of It's an open question whether we want to define this symbol prior to including format.h in our |
||
|
||
#include "absl/strings/string_view.h" | ||
#include "fmt/format.h" | ||
#include "fmt/ostream.h" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
#include "common/grpc/common.h" | ||
|
||
#include <arpa/inet.h> | ||
|
||
#include <atomic> | ||
#include <cstdint> | ||
#include <cstring> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you upstream this? Patches aren't sustainable for us long term.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will not be accepted upstream until a version major bump (note it is our patch - of envoy's present patch.) PR and discussion item here; nghttp2/nghttp2#1395
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ack, please leave a reference to this thread in the
patches
arg of the_repository_impl
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added footnote of ABI compat/next major release, discussion pointer to nghttp2/nghttp2#1395