r17565: expand the test for negative enum values, systems like Tru64
authorStefan Metzmacher <metze@samba.org>
Wed, 16 Aug 2006 06:04:36 +0000 (06:04 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 19:15:37 +0000 (14:15 -0500)
truncate the value to INT_MAX...
So a AC_TRY_RUN test is needed here

metze
(This used to be commit dc0e22a52e3488a4cb9f17138389885183e90c34)

source4/build/m4/check_cc.m4

index 4850ec5504e1df4b93df6096a4d89f96c84c5157..c15da03637322139fd7dc1b74cbaf7e82f7f53e8 100644 (file)
@@ -86,11 +86,28 @@ fi
 
 ############################################
 # check if the compiler can handle negative enum values
+# and don't truncate the values to INT_MAX
+# a runtime test is needed here
 AC_CACHE_CHECK([that the C compiler understands negative enum values],SMB_BUILD_CC_NEGATIVE_ENUM_VALUES, [
-    AC_TRY_COMPILE([
-#include <stdio.h>],
+    AC_TRY_RUN(
 [
+       #include <stdio.h>
        enum negative_values { NEGATIVE_VALUE = 0xFFFFFFFF };
+       int main(void) {
+               enum negative_values v1 = NEGATIVE_VALUE;
+               unsigned v2 = NEGATIVE_VALUE;
+
+               if (v1 != 0xFFFFFFFF) {
+                       printf("%u != 0xFFFFFFFF\n", v1);
+                       return 1;
+               }
+               if (v2 != 0xFFFFFFFF) {
+                       printf("%u != 0xFFFFFFFF\n", v2);
+                       return 1;
+               }
+
+               return 0;
+       }
 ],
        SMB_BUILD_CC_NEGATIVE_ENUM_VALUES=yes,SMB_BUILD_CC_NEGATIVE_ENUM_VALUES=no)])
 if test x"$SMB_BUILD_CC_NEGATIVE_ENUM_VALUES" != x"yes"; then