Skip to content
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

duplicate definition of INT8_MAX in Visual Studio 2015 #307

Closed
mathstuf opened this issue Jan 26, 2018 · 8 comments
Closed

duplicate definition of INT8_MAX in Visual Studio 2015 #307

mathstuf opened this issue Jan 26, 2018 · 8 comments
Milestone

Comments

@mathstuf
Copy link

In generated source files, this block is done after including inttypes.h, however at least on Visual Studio 2015, these are defined by stdint.h which is included later in the file causing redefinition warnings.

@mathstuf
Copy link
Author

Cc: @mathturtle

@jannick0
Copy link
Contributor

jannick0 commented Jan 26, 2018

Would defining YY_NO_UNISTD_H help, e.g. cl /DYY_NO_UNISTD_H lex.yy.c?

@Explorer09
Copy link
Contributor

Explorer09 commented Jan 31, 2018

This is not flex's fault. inttypes.h should contain the definitions of stdint.h, and if including stdint.h after inttypes.h would cause redefinition warnings, then go fix the headers in your environment.
The definitions you pointed in flexint.h are all conditionally done, and are expected to be included after inttypes.h or stdint.h, you get warnings only if you include in the wrong order.

@mathstuf
Copy link
Author

Hrm, indeed. I'll look into the cause for the warning more. Maybe Visual Studio is not following the standard or stdint.h does different things based on whether other #define's are set and adds these definitions.

@mathstuf
Copy link
Author

OK, so I read the code wrong, inttypes.h is only included after checking __STDC_VERSION__. If not, INT8_MIN is defined unconditionally even though it may be in stdint.h. So it sounds like before trying to define the min/max macros, stdint.h should be included first.

@mathstuf
Copy link
Author

Note that VS 2013 does not implement C99, so it doesn't set a suitable __STDC_VERSION__.

mathstuf added a commit to mathstuf/flex that referenced this issue Jan 31, 2018
These defines are provided by `stdint.h` and it should be included first
before trying to define them manually.

Fixes westes#307.
Explorer09 added a commit to Explorer09/flex that referenced this issue Jan 31, 2018
The [U]INT{8,16,32}_{MIN,MAX} macros are never used in skeleton code.
Having them in skeleton just increases the chance of conflicts in case
that user defines them in non-C99 environment (see issue westes#307, when
flex code is built in Visual C++).

flexint.h is now split in two files. Only "flexint_shared.h" will be
included in skeleton now, which defines flex integral types.
flexint.h contains integer limits macros that would be used in flex
only.
Explorer09 added a commit to Explorer09/flex that referenced this issue Feb 6, 2018
The [U]INT{8,16,32}_{MIN,MAX} macros are never used in skeleton code.
Having them in skeleton just increases the chance of conflicts in case
that user defines them in non-C99 environment (see issue westes#307, when
flex code is built in Visual C++ (before VS2013)).

flexint.h is now split in two files. Only "flexint_shared.h" will be
included in skeleton now, which defines flex integral types.
flexint.h contains integer limits macros that would be used in flex
only.
@Explorer09
Copy link
Contributor

Just for another info, VS 2013 has <inttypes.h> in addition to <stdint.h>, it's just not included in the flex scanner because of the absence of __STDC_VERSION__macro.

@westes westes added this to the 2.6.6 milestone Feb 24, 2018
Explorer09 added a commit to Explorer09/flex that referenced this issue Mar 4, 2018
The [U]INT{8,16,32}_{MIN,MAX} macros are never used in skeleton code.
Having them in skeleton just increases the chance of conflicts in case
that user defines them in non-C99 environment (see issue westes#307, when
flex code is built in Visual C++ (before VS2013)).

flexint.h is now split in two files. Only "flexint_shared.h" will be
included in skeleton now, which defines flex integral types.
flexint.h contains integer limits macros that would be used in flex
only.

Signed-off-by: Kang-Che Sung <explorer09@gmail.com>
Explorer09 added a commit to Explorer09/flex that referenced this issue Mar 8, 2018
The [U]INT{8,16,32}_{MIN,MAX} macros are never used in skeleton code.
Having them in skeleton just increases the chance of conflicts in case
that user defines them in non-C99 environment (see issue westes#307, when
flex code is built in Visual C++ (before VS2013)).

flexint.h is now split in two files. Only "flexint_shared.h" will be
included in skeleton now, which defines flex integral types.
flexint.h contains integer limits macros that would be used in flex
only.

Signed-off-by: Kang-Che Sung <explorer09@gmail.com>
@westes westes modified the milestones: 2.6.6, 2.6.5 Mar 8, 2018
westes pushed a commit that referenced this issue Mar 8, 2018
The [U]INT{8,16,32}_{MIN,MAX} macros are never used in skeleton code.
Having them in skeleton just increases the chance of conflicts in case
that user defines them in non-C99 environment (see issue #307, when
flex code is built in Visual C++ (before VS2013)).

flexint.h is now split in two files. Only "flexint_shared.h" will be
included in skeleton now, which defines flex integral types.
flexint.h contains integer limits macros that would be used in flex
only.

Signed-off-by: Kang-Che Sung <explorer09@gmail.com>
@westes
Copy link
Owner

westes commented Mar 8, 2018

Fixed by #309.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants