iosmacroscore-foundation

How to define Max and Min value of CFIndex?


I try to define a macro like this:

#import <CoreFoundation/CFBase.h>

#if __LLP64__
#define CFIndexMax LONG_LONG_MAX;
#define CFIndexMin LONG_LONG_MIN;
#else
#define CFIndexMax LONG_MAX;
#define CFIndexMin LONG_MIN;
#endif

But Xcode always warn me has no define of __LLP64_ which is conditional defined in CFBase.h.


Solution

  • Your problem is that you are checking the value of __LLP64__ but you want to check for the existence of __LLP64__:

    #ifdef __LLP64__
    #define CFIndexMax LONG_LONG_MAX
    #define CFIndexMin LONG_LONG_MIN
    #else
    #define CFIndexMax LONG_MAX
    #define CFIndexMin LONG_MIN
    #endif
    

    However, only Windows uses the LLP64 model. Are you planning to build this code on Windows? If not, you should simplify your code by eliminating the conditional.