mardi 28 juin 2016

Is this macro statement legal C++ or something else? And if it is legal how does it work


WebKit has a lot of pre-processor lines like this: #if MACRO1(MACRO2)

For example:

#if PLATFORM(MAC) || (PLATFORM(QT) && USE(QTKIT))
#include "MediaPlayerPrivateQTKit.h"
#if USE(AVFOUNDATION)
#include "MediaPlayerPrivateAVFoundationObjC.h"
#endif
...

So my first thought was that they were function-like macros, but I can't see how that would work, and I couldn't find any #defines for these macros anywhere in the source code.

I asked another engineer what it was and he's never seen multiple macros used like that inside a #if before either. I found this wiki page that talks about them but it still wasn't clear to me where they come from,

So my question then: Is this valid C++ or is it being replaced in the code by another tool/language like CMake or something else, and if it is valid C++ is there a spec anyone is aware of that talks about this?

I'm a support engineer for a C++ Static Analysis tool that isn't handling this syntax. A customer asked us to handle it, but if I'm going to take this to the senior engineer I'd like to not sound like an idiot :) So I'd like the nitty gritty if anyone knows it.


Aucun commentaire:

Enregistrer un commentaire