Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0006517OCamlOCaml runtime systempublic2014-08-20 10:142014-09-02 16:41
ReporterRichard Jones 
Assigned To 
PrioritynormalSeverityminorReproducibilityalways
StatusresolvedResolutionfixed 
PlatformOSOS Version
Product Version4.02.0+beta1 / +rc1 
Target Version4.03.0+devFixed in Version4.03.0+dev 
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
types.

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. (http://stackoverflow.com/a/228797 [^])

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 0004164acknowledgeddoligez caml C headers may clash with other C libraries 
related to 0004877resolved Definition of uint64 in caml/config.h conflicts. (MacOSX Snow Leopard, X86_64) 

-  Notes
(0012050)
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.
(0012051)
xleroy (administrator)
2014-08-27 12:00

Commit 15131 in SVN trunk uses <stdint.h> plus int32_t, etc instead of int32, etc.
(0012075)
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.
(0012076)
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:

http://pkgs.fedoraproject.org/cgit/ocaml-ocamlnet.git/tree/ [^]

(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
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
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


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker