This is an archive of the discontinued LLVM Phabricator instance.

[sanitizer] if WINAPI is already defined, do not redefine it
ClosedPublic

Authored by inglorion on Feb 7 2017, 2:04 PM.

Details

Summary

lib/sanitizer_common/sanitizer_win_defs.h defineds WINAPI, which is also defined by standard Windows headers. Redefining it causes warnings during compilation. This change causes us to only define WINAPI if it is not already defined, which avoids the warnings.

Diff Detail

Repository
rL LLVM

Event Timeline

inglorion created this revision.Feb 7 2017, 2:04 PM
zturner edited edge metadata.Feb 7 2017, 2:15 PM

How about #include <minwindef.h>

Instead of defining WINAPI ourselves? I would be happy with that. Would you like me to make that change?

Yea it seems like the more correct thing to do, at least to me. Not sure if someone disagrees though.

mpividori edited edge metadata.Feb 7 2017, 3:58 PM

Is minwindef.h provided by MSVC?

Is minwindef.h provided by MSVC?

Yes. Technically it's considered an implementation detail of the windows api, so yous houldn't include it directly. But the value of WINAPI is also an implementation detail.

Including minwindef.h makes the compiler very unhappy, complaining about a lot of undefined types and identifiers. I guess if we wanted to include something, we would have to include something much larger. I think there is a good argument to be made to just define the one macro we care about here. Ok to ship as-is?

mpividori accepted this revision.Feb 7 2017, 4:16 PM
This revision is now accepted and ready to land.Feb 7 2017, 4:16 PM
rnk accepted this revision.Feb 7 2017, 5:02 PM

looks good as is

This revision was automatically updated to reflect the committed changes.