>From INT.h.in: 828 #if !defined(@KWIML@_INT_NO_INTPTR_T) 829 @KWIML@_INT__VERIFY_TYPE(@KWIML@_INT_intptr_t, sizeof(void*)); 830 #endif 831 #if !defined(@KWIML@_INT_NO_UINTPTR_T) 832 @KWIML@_INT__VERIFY_TYPE(@KWIML@_INT_uintptr_t, sizeof(void*)); 833 #endif
Now this statement blows up in the make Makefile process as follows: cmIML_INT__VERIFY_TYPE(cmIML_INT_intptr_t, sizeof(void*)); ^ %CXX-E-NOTCOMPREDEC, declaration is incompatible with "int (*cmIML_INT_intptr_t__VERIFY__)[4U]" (declared at line 829) at line number 829 in file LCL_ROOT:[cmake-3_3_2.Bootstrap_cmk.cmIML]INT.h;11 I wrote a simple C application to confirm the compiler's values, compiled-and-linked the application on both OpenVMS and Fedora Linux (x64) and noticed a discrepancy... ITAN1* ty foo.c #include <stdio.h> #include <stdlib.h> #include <inttypes.h> int main(void) { printf( "sizeof(intptr_t) = %d\n", sizeof(intptr_t)); printf( "sizeof(uintptr_t) = %d\n", sizeof(uintptr_t)); printf( "sizeof(void *) = %d\n", sizeof(void *)); return EXIT_SUCCESS; } On OpenVMS this application displays the following: ITAN1* r foo sizeof(intptr_t) = 8 sizeof(uintptr_t) = 8 sizeof(void *) = 4 sizeof(int *) = 4 and clearly sizeof(void *) = 4 < does NOT equal > sizeof(intptr_t) = 8 On Fedora22 the exact same application displays the following: [jpcustin@localhost ~]$ ./foo sizeof(intptr_t) = 8 sizeof(uintptr_t) = 8 sizeof(void *) = 8 sizeof(int *) = 8 [jpcustin@localhost ~]$ http://en.cppreference.com/w/c/types/integer describes intptr_t as: "integer type capable of holding a pointer" http://pubs.opengroup.org/onlinepubs/009695399/basedefs/stdint.h.html goes a little further: Integer types capable of holding object pointers The following type designates a signed integer type with the property that any valid pointer to void can be converted to this type, then converted back to a pointer to void, and the result will compare equal to the original pointer: intptr_t The following type designates an unsigned integer type with the property that any valid pointer to void can be converted to this type, then converted back to a pointer to void, and the result will compare equal to the original pointer: uintptr_t This begs the question... Why does the CMake test rely on checking if sizeof(intptr_t) equals sizeof(void *) instead of sizeof(intptr_t) greater than or equal to sizeof(void *) (so can an intptr_t "hold" a void *)? JayC -- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://public.kitware.com/mailman/listinfo/cmake