diff options
author | Steve Hay <steve.m.hay@googlemail.com> | 2018-04-28 13:56:05 +0100 |
---|---|---|
committer | Steve Hay <steve.m.hay@googlemail.com> | 2018-04-28 13:56:05 +0100 |
commit | 4bd4e9335ffc257cbe2bf1a42789f693f5797337 (patch) | |
tree | f366c7e1e29519b9e9aac55eb709b0772282f94a | |
parent | 9fba38f0c306686a0a62e378ff28e2cd58fb0fbb (diff) | |
download | perl-4bd4e9335ffc257cbe2bf1a42789f693f5797337.tar.gz |
Finally fix C++ build with VS2017
Dodge the "offsetof has a builtin meaning; use /Zc:offsetof- to revert to
old, non-conforming definition" error when compiling Socket.xs by reverting
to an old definition of STRUCT_OFFSET for that compiler.
-rw-r--r-- | perl.h | 11 |
1 files changed, 9 insertions, 2 deletions
@@ -1040,8 +1040,15 @@ EXTERN_C int usleep(unsigned int); # define PERL_STRLEN_EXPAND_SHIFT 2 #endif -#include <stddef.h> -#define STRUCT_OFFSET(s,m) offsetof(s,m) +/* This use of offsetof() requires /Zc:offsetof- for VS2017 (and presumably + * onwards) when building Socket.xs, but we can just use a different definition + * for STRUCT_OFFSET instead. */ +#if defined(WIN32) && defined(_MSC_VER) && _MSC_VER >= 1910 +# define STRUCT_OFFSET(s,m) (Size_t)(&(((s *)0)->m)) +#else +# include <stddef.h> +# define STRUCT_OFFSET(s,m) offsetof(s,m) +#endif /* ptrdiff_t is C11, so undef it under pedantic builds */ #ifdef PERL_GCC_PEDANTIC |