[cairo] cairomm: Visual Studio WIN32 define clash with Surface::Type::WIN32
hlewin at gmx.de
Thu Jan 7 00:25:43 UTC 2021
Can't you just "#define WIN32 WIN32"?
Am 06.01.2021 um 11:05 schrieb Francesco Pretto:
> I'm experiencing a clash between the very commonly defined macro WIN32
> and the Surface::Type::WIN32 enum identifier. Basically WIN32 is
> default defined in all Visual Studio IDE projects (.vcxproj projects),
> and there's not much to do about it: a regular Visual Studio project
> trying to use cairomm will fail building because of expansion of the
> Surface::Type::WIN32 identifier to 1. I elaborate a bit more about
> default defined macros in Windows/Visual Studio world:
> 1) MSVC **compiler** (not msbuild project build configuration)
> intrinsically defines _WIN32. This is officially documented in this
> page ;
> 2) Historically all Visual Studio versions also default defines WIN32
> macro for IDE built projects. I can't find official statements about
> it but there are many mentions about this and it can be easily
> tested by creating a command line project and specifically checking
> against the WIN32 define. Also very relevant: CMake generated projects
> also define WIN32, and you can test it easily or read the words of the
> project maintainer Brad King. Much software will break if WIN32 is
> not defined, in my experience much more than 50% of software either
> using WIN32 or _WIN32.
> Because of the reasons in 2) the choice for cairomm of naming an
> identifier WIN32 was unlucky and unfortunate, and if you want to the
> library to be usable in commonly run Visual Studio environments
> there's not much choice other than breaking the API and rename the
> Surface::Type::WIN32 identifier to something else. My suggestion is
> - Surface::Type::WIN32 -> Surface::Type::WIN32GDI;
> - For sake of consistency also WIN32_PRINTING could be renamed
> to WIN32GDI_PRINTING, but this is optional.
> I guess the amount of users that would break with this change is very
> low. Also it would be a non breaking ABI change. I'm not the right
> person to talk about this, though.
> Attached the patch that does rename. It can also be used as a
> temporary fix for users that want to use cairomm in a VS built project.
>  https://stackoverflow.com/a/662543/213871
>  https://cmake.org/Bug/view.php?id=14827#c35569
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the cairo