bool.c 845 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. // TEST_CFLAGS -funsigned-char
  2. // (verify -funsigned-char doesn't change the definition of BOOL)
  3. #include "test.h"
  4. #include <objc/objc.h>
  5. #if TARGET_OS_OSX
  6. # define RealBool 0
  7. #elif TARGET_OS_IOS || TARGET_OS_BRIDGE
  8. # if (__arm__ && !__armv7k__) || __i386__
  9. # define RealBool 0
  10. # else
  11. # define RealBool 1
  12. # endif
  13. #else
  14. # define RealBool 1
  15. #endif
  16. #if __OBJC__ && !defined(__OBJC_BOOL_IS_BOOL)
  17. # error no __OBJC_BOOL_IS_BOOL
  18. #endif
  19. #if RealBool != OBJC_BOOL_IS_BOOL
  20. # error wrong OBJC_BOOL_IS_BOOL
  21. #endif
  22. #if RealBool == OBJC_BOOL_IS_CHAR
  23. # error wrong OBJC_BOOL_IS_CHAR
  24. #endif
  25. int main()
  26. {
  27. const char *expected __unused =
  28. #if RealBool
  29. "B"
  30. #else
  31. "c"
  32. #endif
  33. ;
  34. #if __OBJC__
  35. const char *enc = @encode(BOOL);
  36. testassert(0 == strcmp(enc, expected));
  37. #endif
  38. succeed(__FILE__);
  39. }