Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0006517OCamlruntime system and C interfacepublic2014-08-20 10:142016-12-07 11:34
ReporterRichard Jones 
Assigned To 
PlatformOSOS Version
Product Version4.02.0+beta1 / +rc1 
Target Version4.03.0+dev / +beta1Fixed in Version4.03.0+dev / +beta1 
Summary0006517: It would be nice if <caml/*.h> didn't define types like "int64"
DescriptionHeaders like <caml/config.h> define a number of types without
a caml_ prefix. Unfortunately these types have very generic names
like "int64" which clash with other headers which also define these

As an example it is not possible to combine the headers:

 #include <caml/config.h>
 #include <tiffio.h>

which currently causes compilation problems in camlimages.

Note that it is illegal to define any identifier ending in *_t in C99.
All of these are reserved for C. ( [^])

The full list of problematic types is:

* int32 defined in caml/config.h
* uint32 defined in caml/config.h
* int64 defined in caml/config.h
* uint64 defined in caml/config.h
* asize_t defined in caml/misc.h
* header_t defined in caml/mlvalues.h
* mlsize_t in caml/mlvalues.h
* tag_t in caml/mlvalues.h
* color_t in caml/mlvalues.h
* mark_t in caml/mlvalues.h
* opcode_t in caml/mlvalues.h
* intnat in caml/config.h
* uintnat in caml/config.h
* value in caml/mlvalues.h

Of these, int32, uint32, int64 and uint64 are the most problematic, and
seem to be the ones which could be changed with little effort. OCaml
should use the standard C99 types like int32_t etc.

The *_t typedefs are illegal as noted above.

Likely it will be impossible to get rid of value since it is used all
over the place by OCaml bindings.
Steps To ReproduceTo get a list of types defined by a header, do:

  echo '#include <caml/config.h>' > types.c
  gcc -c types.c -fdump-ada-spec

and then examine the *.ads files in the current directory.
TagsNo tags attached.
Attached Files

- Relationships
related to 0004164closeddoligez caml C headers may clash with other C libraries 
related to 0004877closed Definition of uint64 in caml/config.h conflicts. (MacOSX Snow Leopard, X86_64) 

-  Notes
xleroy (administrator)
2014-08-26 17:26

I agree that we should change int32, uint32, int64 and uint64 to their C99 equivalents (with the usual hacks for MSVC). I'm afraid we have to live with the other types for backward compatibility: changing e.g. "value" would break a zillion Caml-C stub codes.
xleroy (administrator)
2014-08-27 12:00

Commit 15131 in SVN trunk uses <stdint.h> plus int32_t, etc instead of int32, etc.
frisch (developer)
2014-09-02 15:16

The change still breaks Caml-C stub around. For instance, in camlzip, there is a reference to uint32 which needs to be changed to uint32_t. OPAM will hopefully allow us to identify quickly all packages that need to be updated.
Richard Jones (reporter)
2014-09-02 16:41

Yup a few packages need updating. Fedora has integrated this patch into our OCaml 4.02.0 release, and have patched a few packages as a result. I've sent the patches upstream, where I can easily find an upstream contact, but you can also check our git repo for each package, eg: [^]

(replace ocaml-ocamlnet with Fedora package name)

- Issue History
Date Modified Username Field Change
2014-08-20 10:14 Richard Jones New Issue
2014-08-20 10:21 doligez Relationship added related to 0004164
2014-08-20 10:21 doligez Status new => confirmed
2014-08-20 10:21 doligez Target Version => 4.03.0+dev / +beta1
2014-08-26 17:26 xleroy Note Added: 0012050
2014-08-27 12:00 xleroy Note Added: 0012051
2014-08-27 12:00 xleroy Status confirmed => resolved
2014-08-27 12:00 xleroy Resolution open => fixed
2014-08-27 12:00 xleroy Fixed in Version => 4.03.0+dev / +beta1
2014-08-27 12:01 xleroy Relationship added related to 0004877
2014-09-02 15:16 frisch Note Added: 0012075
2014-09-02 16:41 Richard Jones Note Added: 0012076
2016-12-07 11:34 xleroy Status resolved => closed
2017-02-23 16:43 doligez Category OCaml runtime system => runtime system
2017-03-03 17:45 doligez Category runtime system => runtime system and C interface

Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker