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

Macros min/max conflicts on Windows with Visual Studio 2015 #451

Closed
nauhygon opened this issue May 4, 2017 · 3 comments
Closed

Macros min/max conflicts on Windows with Visual Studio 2015 #451

nauhygon opened this issue May 4, 2017 · 3 comments

Comments

@nauhygon
Copy link
Contributor

nauhygon commented May 4, 2017

I wanted to test out SBE so I tried the cppbuild on Windows with Visual Studio 2015. The benchlet-sbe-*-runner failed to compile due to issues like the one below.

Error	C2589	'(': illegal token on right side of '::'	benchlet-sbe-car-runner	
D:\sbe\cppbuild\Release\generated\uk_co_real_logic_sbe_benchmarks\Car.h	870	

It turned out that the SBE_NULLVALUE_* macros were using std::numeric_limits<T>::min() and std::numeric_limits<T>::max, which conflicted with the min and max macros in Windows header winnt.h. The following change to suppress the macro expansions made the problem go away.

Old:

#define SBE_NULLVALUE_INT8 std::numeric_limits<std::int8_t>::min()
#define SBE_NULLVALUE_INT16 std::numeric_limits<std::int16_t>::min()
#define SBE_NULLVALUE_INT32 std::numeric_limits<std::int32_t>::min()
#define SBE_NULLVALUE_INT64 std::numeric_limits<std::int64_t>::min()
#define SBE_NULLVALUE_UINT8 std::numeric_limits<std::uint8_t>::max()
#define SBE_NULLVALUE_UINT16 std::numeric_limits<std::uint16_t>::max()
#define SBE_NULLVALUE_UINT32 std::numeric_limits<std::uint32_t>::max()
#define SBE_NULLVALUE_UINT64 std::numeric_limits<std::uint64_t>::max()

New:

#define SBE_NULLVALUE_INT8 (std::numeric_limits<std::int8_t>::min)()
#define SBE_NULLVALUE_INT16 (std::numeric_limits<std::int16_t>::min)()
#define SBE_NULLVALUE_INT32 (std::numeric_limits<std::int32_t>::min)()
#define SBE_NULLVALUE_INT64 (std::numeric_limits<std::int64_t>::min)()
#define SBE_NULLVALUE_UINT8 (std::numeric_limits<std::uint8_t>::max)()
#define SBE_NULLVALUE_UINT16 (std::numeric_limits<std::uint16_t>::max)()
#define SBE_NULLVALUE_UINT32 (std::numeric_limits<std::uint32_t>::max)()
#define SBE_NULLVALUE_UINT64 (std::numeric_limits<std::uint64_t>::max)()

BTW, awesome work on SBE and Aeron. Many thanks!

@tmontgomery
Copy link
Contributor

Thanks! Feel free to send in a PR for this.

nauhygon added a commit to nauhygon/simple-binary-encoding that referenced this issue May 8, 2017
tmontgomery added a commit that referenced this issue May 8, 2017
#451: Fix min/max macro conflicts on Windows
@nauhygon
Copy link
Contributor Author

nauhygon commented May 8, 2017

Thanks for merging the PR. Closing this issue.

@nauhygon nauhygon closed this as completed May 8, 2017
@tmontgomery
Copy link
Contributor

Thanks for submitting the PR!

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

No branches or pull requests

2 participants