[cairo] cairomm: Visual Studio WIN32 define clash with Surface::Type::WIN32
James K. Lowden
jklowden at schemamania.org
Wed Jan 6 23:08:14 UTC 2021
On Wed, 6 Jan 2021 18:14:08 +0100
Petr Kobalí?ek <kobalicek.petr at gmail.com> wrote:
> 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.
I like your suggestion because it preserves already working code.
Myself, I'm more willing to require new users -- Windows users in
particular -- to learn about standards and to avoid undocumented
nonstandard conventions. But your idea of an alias preserves working
code and allows for a transition in the indefinite future.
I have two modifications to your suggestion.
You suggest
Surface::Type::WIN32GDI
but IIRC "GDI" is a term of art in Windows. Unless that was your
intention, I suggest
Surface::Type::WIN32SURFACE
instead.
The push/pop pragmas won't work outside Visual Studio, and there are
several ways to compile for Windows without using Microsoft's
compiler.
I think this is equivalent and portable:
#ifdef WIN32
#define WIN32_WAS_SET WIN32
#undef WIN32
#endif
....
#ifdef WIN32_WAS_SET
#define WIN32 WIN32_WAS_SET
#undef WIN32_WAS_SET
#endif
--jkl
More information about the cairo
mailing list