<div dir="ltr">You can do that with #pragma push_macro() / pop_macro(), see:<div><br><div>  <a href="https://docs.microsoft.com/en-us/cpp/preprocessor/push-macro?view=msvc-160">https://docs.microsoft.com/en-us/cpp/preprocessor/push-macro?view=msvc-160</a></div><div><br></div><div>I think that compatibility with various libraries and build systems is always a greater deal than opinions about what's right or wrong. The problem can be fixed by introducing a synonym to WIN32 (name already proposed) together with still providing the old WIN32 name guarded by push_macro() / pop_macro() - that way no project would break and new projects can start using the new symbol instead.</div><div><br></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Jan 6, 2021 at 4:56 PM Francesco Pretto <<a href="mailto:ceztko@gmail.com">ceztko@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Hello James. I reply below.</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, 6 Jan 2021 at 16:05, James K. Lowden <<a href="mailto:jklowden@schemamania.org" target="_blank">jklowden@schemamania.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Wed, 6 Jan 2021 11:05:24 +0100<br>
<br>
The best solution ISTM is to add<br>
<br>
        #undef WIN32<br>
<br>
somewhere early in the Cairo header files, and document it<br>
accordingly.  Short of that, document it only, and caveat emptor.<br>
Developers should minimize use of the preprocessor, and definitely<br>
not define macros that don't need to be defined!  <br>
<br></blockquote><div><br></div><div>I just tried a quick "hello world" program and this does not seem to work to me, or it doesn't</div><div>seems to be a viable solution, unless you point me how it is supposed to work. I show what you what I tried:</div><div>

-----------------------

</div><div>#ifdef WIN32<br>#undef WIN32<br>#define WIN32_WAS_SET<br>#endif<br><br>enum class TestEnum<br>{<br>    WIN32<br>};<br><br>#ifdef WIN32_WAS_SET<br>#define WIN32 1<br>#endif<br><br>int main()<br>{<br>    TestEnum enm = TestEnum::WIN32; // Doesn't compile anyway in VS2019</div><div>    return 0;<br>}<br></div><div>-----------------------</div><div><br></div><div>Re-defining WIN32 if it was found defined is a must, because it would be bullying, if not "criminal", to just undef it, potentially breaking outer software that legitimately use it.</div><div>Is there a way to escape the TestEnum::WIN32 identifier in C++ in this case? Consider that I'd prefer to not use odd solutions, but still show me what you suggested.</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
>  or read the words of the project maintainer Brad King[3].<br>
<br>
As I read his words, he was asking for the nonexistent, namely official<br>
Microsoft documentation for WIN32.  Four years ago he said that 14<br>
years prior CMake had defined WIN32 because "the project ... wanted it<br>
defined". Two decades ago, that was common practice.  No need to<br>
promulgate it further today.  <br><br></blockquote><div><br></div><div>When the implications are very small (and I think we are in this domain) I think that library developers should be pragmatic and not waste their resources in fighting against windmills. WIN32 is still defined today in all default projects in latest VS 2019, and all projects generated by the latest CMake version. Unless there is a 100% working solution that keeps the WIN32 identifier and that doesn't possibly break any correct use of the WIN32 macro, as defined by the SDK, the build system or the user, the wiser choice would be to just assume WIN32 is a reserved word when compiling under Visual Studio.</div><div><br></div><div>Regards,</div><div>Francesco</div></div></div>
-- <br>
cairo mailing list<br>
<a href="mailto:cairo@cairographics.org" target="_blank">cairo@cairographics.org</a><br>
<a href="https://lists.cairographics.org/mailman/listinfo/cairo" rel="noreferrer" target="_blank">https://lists.cairographics.org/mailman/listinfo/cairo</a><br>
</blockquote></div>