Search code examples
cwindowsc-preprocessorconditional-compilation

What does "#if ..." (with an ellipsis) do?


I was doing some studying of the windows header files and I came upon a preprocessor statement that I didn't recognize. I've been searching for any information on this statement for about a week and I can't find any information on it anywhere. I'm not sure if it's just not a search engine friendly phrase or if there really isn't much on the web about it. I've found a couple uses of this preprocessor in the MS header files.

Here is an example from this page:

typedef struct _SID {
    BYTE Revision;
    BYTE SubAuthorityCount;
    SID_IDENTIFIER_AUTHORITY IdentifierAuthority;
    #if ...
        DWORD * SubAuthority[];
    #else
        DWORD SubAuthority[ANYSIZE_ARRAY];
    #endif
} SID, *PSID;

Note: I'm asking specifically about #if ..., with an ellipsis.

Can someone please elaborate what the preprocessor #if ... does? Any help would be greatly appreciated.


Solution

  • The documentation page the code was linked from was not meant to reflect what's actually in the condition of the #if directive. It's only there to show what the options are in terms of what's defined.

    The actual winnt.h header on my system (under C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Include) has the following

    typedef struct _SID {
       BYTE  Revision;
       BYTE  SubAuthorityCount;
       SID_IDENTIFIER_AUTHORITY IdentifierAuthority;
    #ifdef MIDL_PASS
       [size_is(SubAuthorityCount)] DWORD SubAuthority[*];
    #else // MIDL_PASS
       DWORD SubAuthority[ANYSIZE_ARRAY];
    #endif // MIDL_PASS
    } SID, *PISID;
    

    So there's no actual ... after #if. It's just there in the documentation for brevity.