24 ms·
Is it just me, or is this just an extremely convoluted way of doing things? I know it says it is a trick, but I'm not sure I completely get it.
by jaybosamiya 11y ago
Is it just me, or is this just an extremely convoluted way of doing things?
I know it says it is a trick, but I'm not sure I completely get it.
- klodolph 11y agoI agree... if I see an `#if defined _WIN32` I know what I'm looking at, but this trick would be a complete surprise.
- Noughmad 11y agoIt is. The page starts with talk about namespaces and such, so one thinks this will be about some cool new features of C++11, but instead ends with a global #define. Yes, coding like this is evil and will eat your hamster. For example, trying to have a variable named "platform" will break your code in strange ways. And before you say "but it's C++, it's modern", CppCoreGuidelines explicitly say this is bad and that one should favor #ifdefs. (https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#es30-dont-use-macros-for-program-text-manipulation https://github.com/isocpp/CppCoreGuidelines/blob/master/CppC...)
- dchichkov 11y agoauthor Yes, "PLATFORM" should be clearly marked with uppercase. Fixed. Thank you. There have to be some kind of "-DPLATFORM=arm" definition, one have to tell to the compiler in some way what hardware we are running on...