Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0004877OCaml~DO NOT USE (was: OCaml general)public2009-09-30 20:462016-12-07 11:34
Assigned To 
PlatformOSOS Version
Product Version3.11.1 
Target Version4.03.0+dev / +beta1Fixed in Version4.03.0+dev / +beta1 
Summary0004877: Definition of uint64 in caml/config.h conflicts. (MacOSX Snow Leopard, X86_64)
DescriptionConflict of the uint64 definition prevents to define external functions using Cocoa API.

$ cat test.m
#include <caml/config.h>
#import <Cocoa/Cocoa.h>

$ cc -I /opt/local/lib/ocaml test.m
In file included from /System/Library/Frameworks/Security.framework/Headers/Security.h:24,
                 from /System/Library/Frameworks/Foundation.framework/Headers/NSURLCredential.h:14,
                 from /System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:79,
                 from /System/Library/Frameworks/Cocoa.framework/Headers/Cocoa.h:12,
                 from test.m:2:
/System/Library/Frameworks/Security.framework/Headers/cssmconfig.h:53: error: conflicting types for ‘uint64’
/opt/local/lib/ocaml/caml/config.h:128: error: previous declaration of ‘uint64’ was here
$ sed -n 53p < /System/Library/Frameworks/Security.framework/Headers/cssmconfig.h
typedef uint64_t uint64;
$ grep "typedef.*uint64_t;" /usr/lib/gcc/i686-apple-darwin10/4.2.1/include/stdint.h
typedef unsigned long long uint64_t;
$ sed -n 128p < /opt/local/lib/ocaml/caml/config.h
typedef ARCH_UINT64_TYPE uint64;
$ grep "#define.*ARCH_UINT64_TYPE" /opt/local/lib/ocaml/caml/config.h
#define ARCH_UINT64_TYPE unsigned long

A patch attached to this report will resolve this problem.

I guess ppc64 architecture also has same problem and this patch resolve it.
Additional Information$ uname -v
Darwin Kernel Version 10.0.0: Fri Jul 31 22:47:34 PDT 2009; root:xnu-1456.1.25~1/RELEASE_I386
$ sw_vers
ProductName: Mac OS X
ProductVersion: 10.6.1
BuildVersion: 10B504
$ port version
Version: 1.8.1
$ port list installed | grep ocaml
ocaml @3.11.1 lang/ocaml
$ cc -verson
i686-apple-darwin10-gcc-4.2.1: no input files
TagsNo tags attached.
Attached Filesdiff file icon patch-configure.diff [^] (433 bytes) 2009-09-30 20:46 [Show Content]

- Relationships
related to 0001956acknowledgeddoligez Name clashes 
related to 0004164closeddoligez caml C headers may clash with other C libraries 
related to 0006517closed It would be nice if <caml/*.h> didn't define types like "int64" 

-  Notes
monipol (reporter)
2010-01-22 04:00

Hello, kiyoshi. Does your patch prevent uint64 from being defined on Mac OS X? What if <caml/config.h> is being used by a non-Cocoa, non-Carbon program that's supposed to build on Mac OS X — wouldn't uint64 need to be defined by OCaml then?

One alternative solution would be config.h to consider a new macro that would determine whether config.h should define those types or not.

For what it's worth, this issue also affects Mac OS 10.5 (Leopard) when building 64-bit programs that use both Cocoa and OCaml.
kiyoshi (reporter)
2010-01-28 12:33

Hi, monipol.

> Does your patch prevent uint64 from being defined on Mac OS X?

My patch only affects lines on "m.h" generated by config script.

Please look at the config file affected by my patch:
 echo "#define SIZEOF_PTR $3" >> m.h
 echo "#define SIZEOF_SHORT $4" >> m.h
-if test $2 = 8; then
+if test $2 = 8 && $system != macosx; then
      echo "#define ARCH_INT64_TYPE long" >> m.h
      echo "#define ARCH_UINT64_TYPE unsigned long" >> m.h
      echo '#define ARCH_INT64_PRINTF_FORMAT "l"' >> m.h
   sh ./runtest longlong.c
   case $? in
   0) echo "64-bit \"long long\" integer type found (printf with \"%ll\")."
      echo "#define ARCH_INT64_TYPE long long" >> m.h
      echo "#define ARCH_UINT64_TYPE unsigned long long" >> m.h
      echo '#define ARCH_INT64_PRINTF_FORMAT "ll"' >> m.h
Execution of original configure script on 64-bit Mac OS X processes 'then' part, so uint64 is defined as "long".
This type is not equals to "long long", the type of uint64 defined in /System/Library/Frameworks/Security.framework/Headers/cssmconfig.h.

In the case of the script my patch applied, "else" pat is executed.
Execution of "runtiest longlong.c" returns 0, so uint64 is defined as "long long", and the result is no type conflict errors.

I think that you can select 64/32-bit binary with C-compiler options so that "runtest sizes.c" returns the expected value:
echo "Checking the sizes of integers and pointers..."
set `sh ./runtest sizes.c`
case "$2,$3" in
  4,4) echo "OK, this is a regular 32 bit architecture."
       echo "#undef ARCH_SIXTYFOUR" >> m.h
  *,8) echo "Wow! A 64 bit architecture!"
       echo "#define ARCH_SIXTYFOUR" >> m.h
  *,*) echo "This architecture seems to be neither 32 bits nor 64 bits."
       echo "Objective Caml won't run on this architecture."
       exit 2;;
    *) echo "Unable to compile the test program."
       echo "Make sure the C compiler $cc is properly installed."
       exit 2;;
For example, 'configure -cc "cc -arch x86_64"; make world' on Mac OS X 10.5 will generate 64-bit binaries.
doligez (administrator)
2012-09-17 17:34

Watch out, there is a bug in the patch.

This problem should be properly solved when we fix PR#4164.
xleroy (administrator)
2014-08-27 12:02

See 6517 for more info.

- Issue History
Date Modified Username Field Change
2009-09-30 20:46 kiyoshi New Issue
2009-09-30 20:46 kiyoshi File Added: patch-configure.diff
2010-01-22 04:00 monipol Note Added: 0005232
2010-01-28 12:33 kiyoshi Note Added: 0005234
2011-05-31 16:51 doligez Status new => acknowledged
2012-07-11 14:50 doligez Target Version => 4.01.0+dev
2012-07-31 13:36 doligez Target Version 4.01.0+dev => 4.00.1+dev
2012-09-17 17:34 doligez Note Added: 0008096
2012-09-17 17:34 doligez Target Version 4.00.1+dev => 4.01.0+dev
2012-09-17 17:34 doligez Relationship added related to 0001956
2012-09-17 17:34 doligez Relationship added related to 0004164
2013-08-12 15:49 doligez Target Version 4.01.0+dev => 4.01.1+dev
2014-05-25 20:20 doligez Target Version 4.01.1+dev => 4.02.0+dev
2014-07-31 16:09 doligez Target Version 4.02.0+dev => 4.03.0+dev / +beta1
2014-08-27 12:01 xleroy Relationship added related to 0006517
2014-08-27 12:02 xleroy Note Added: 0012052
2014-08-27 12:02 xleroy Status acknowledged => resolved
2014-08-27 12:02 xleroy Resolution open => fixed
2014-08-27 12:02 xleroy Fixed in Version => 4.03.0+dev / +beta1
2016-12-07 11:34 xleroy Status resolved => closed
2017-02-23 16:36 doligez Category OCaml general => -OCaml general
2017-03-03 17:55 doligez Category -OCaml general => -(deprecated) general
2017-03-03 18:01 doligez Category -(deprecated) general => ~deprecated (was: OCaml general)
2017-03-06 17:04 doligez Category ~deprecated (was: OCaml general) => ~DO NOT USE (was: OCaml general)

Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker