Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Windows assumes default alignment in their SDKs, so pacing needs to be done after `#include <windows.h>` or defining `WINDOWS_IGNORE_PACKING_MISMATCH`.
- Loading branch information
5ccb00a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You have no idea how much this git comment has helped me.
The compiler showed
error C2118: negative subscript
message at line 2487 inwinnt.h
with Windows 10 SDK 10.0.18362.0.Moving the line
#pragma pack(push,1)
solved the problem.5ccb00a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto. BTW, putting includes inside
extern "C" { ... }
can easily create troubles too. It's best to avoid it.5ccb00a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jrfonseca I think
extern "C"
can cause problems only for C++ headers, wrapping C headers inextern "C"
is totally fine.5ccb00a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True to some extent. The issue is that the distinction between C and C++ headers is not clear cut: one can find C++ code on C headers like math.h and windows headers. Nowadays system headers seem to enclose that code in
extern C++ {..}
precisely to avoid this issue, but in the past this would definitely cause troubles.