From 0d2277bca5fc1c259efca59adff9caaf247f1974 Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Mon, 19 Oct 2020 11:17:43 -0700 Subject: [PATCH] Include in YACC/Bison parsers if necessary. MSVC doesn't, by default, define __STDC_VERSION__, which means that the code generated by newer versions of winflexbison3's Bison end up defining YYPTRDIFF_T as long, which is wrong on 64-bit Windows, as that's an LLP64 platform, not an LP64 platform, and causes warnings to be generated. Those warnings turn into errors. With MSVC, if __STDC_VERSION__ isn't defined, Forcibly include here to work around that. Fixes #16924. --- epan/protobuf_lang.y.in | 14 ++++++++++++++ wiretap/ascend.y.in | 14 ++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/epan/protobuf_lang.y.in b/epan/protobuf_lang.y.in index b031bfb6c5..9d81a64326 100644 --- a/epan/protobuf_lang.y.in +++ b/epan/protobuf_lang.y.in @@ -48,6 +48,20 @@ ${YACC_PURE_PARSER_DIRECTIVE} */ #include "config.h" +#if defined(_MSC_VER) && !defined(__STDC_VERSION__) + /* + * MSVC doesn't, by default, define __STDC_VERSION__, which + * means that the code generated by newer versions of winflexbison3's + * Bison end up defining YYPTRDIFF_T as long, which is wrong on + * 64-bit Windows, as that's an LLP64 platform, not an LP64 platform, + * and causes warnings to be generated. Those warnings turn into + * errors. + * + * With MSVC, if __STDC_VERSION__ isn't defined, Forcibly include + * here to work around that. + */ + #include +#endif #include #include #include diff --git a/wiretap/ascend.y.in b/wiretap/ascend.y.in index cbc9f91a7b..0b4dafe803 100644 --- a/wiretap/ascend.y.in +++ b/wiretap/ascend.y.in @@ -144,6 +144,20 @@ XMIT-Max7:20: (task "_brouterControlTask" at 0xb094ac20, time: 1481.51) 20 octet #include "config.h" +#if defined(_MSC_VER) && !defined(__STDC_VERSION__) + /* + * MSVC doesn't, by default, define __STDC_VERSION__, which + * means that the code generated by newer versions of winflexbison3's + * Bison end up defining YYPTRDIFF_T as long, which is wrong on + * 64-bit Windows, as that's an LLP64 platform, not an LP64 platform, + * and causes warnings to be generated. Those warnings turn into + * errors. + * + * With MSVC, if __STDC_VERSION__ isn't defined, Forcibly include + * here to work around that. + */ + #include +#endif #include #include