Include <stdint.h> 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
<stdint.h> here to work around that.

Fixes #16924.
This commit is contained in:
Guy Harris 2020-10-19 11:17:43 -07:00
parent a76c11e290
commit 0d2277bca5
2 changed files with 28 additions and 0 deletions

View File

@ -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
* <stdint.h> here to work around that.
*/
#include <stdint.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

View File

@ -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
* <stdint.h> here to work around that.
*/
#include <stdint.h>
#endif
#include <stdlib.h>
#include <string.h>