Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] Camlidl and order of include files
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2001-10-30 (23:08)
From: John Gerard Malecki <johnm@a...>
Subject: [Caml-list] Camlidl and order of include files

I just tried camlidl and am not sure if I am using it wrong or if I
have encountered a bug.  I want to access the (solaris) sysconf system
routine to find out how many processors on a machine.  I wrote this
idl file

  quote(C,"#include <unistd.h>")
  enum sysconf_names {
  long sysconf([in] enum sysconf_names name);

I put this file in the camlidl-1.02/tests directory and executed 'make
sysconf.o' only to get

  ../compiler/camlidl -header sysconf.idl
  ocamlc -I ../lib -c sysconf.mli
  ocamlc -I ../lib -c
  gcc -Wall -I.. -I/home/vtools/sun4os5/apps/ocaml-3.02/lib/ocaml -c sysconf.c
  In file included from sysconf.c:16:
  sysconf.h:17: `_SC_NPROCESSORS_ONLN' undeclared here (not in a function)
  sysconf.h:17: enumerator value for `SC_NPROCESSOR_ONLN' not integer constant

When I look in sysconf.c I notice

  #include "sysconf.h"
  #include <unistd.h>

If I change this order to

  #include <unistd.h>
  #include "sysconf.h"

The program now compiles and I am able to successfully use the code.

  :; cat
  let _ =
    Printf.printf "sysconf ==> %d\n"
      (Sysconf.sysconf Sysconf.SC_NPROCESSOR_ONLN)
  :; ocamlc -c 
  :; ocamlc -custom sysconf.cmo test_sysconf.cmo sysconf.o
  :; ./a.out
  sysconf ==> 2

Am I making proper use of camlidl?
Bug reports:  FAQ:
To unsubscribe, mail  Archives: