ola::InitLogging binding pasted by retroj on Tue May 12 16:27:32 2015

(define-foreign-enum-type (log-level int)
  (log-level->int int->log-level)
  (log-level/none ola::OLA_LOG_NONE)
  (log-level/fatal ola::OLA_LOG_FATAL)
  (log-level/warn ola::OLA_LOG_WARN)
  (log-level/info ola::OLA_LOG_INFO)
  (log-level/debug ola::OLA_LOG_DEBUG)
  (log-level/max ola::OLA_LOG_MAX))

(define-foreign-enum-type (log-output int)
  (log-output->int int->log-output)
  (log-output/stderr ola::OLA_LOG_STDERR)
  (log-output/syslog ola::OLA_LOG_SYSLOG)
  (log-output/null ola::OLA_LOG_NULL))

(define init-logging
  (case-lambda
   ((level output)
    ((foreign-lambda bool "ola::InitLogging" log-level log-output)
     level output))
   ((level)
    (init-logging level log-output/stderr))
   (()
    (init-logging log-level/warn log-output/stderr))))

build log pasted by retroj on Tue May 12 16:32:08 2015

retrieving ...
checking platform for `ola' ...
checking dependencies for `ola' ...
install order:
("ola")
installing ola: ...
changing current directory to .
  '/usr/local/bin/csi' -bnq -setup-mode -e "(require-library setup-api)" -e "(import setup-api)" -e "(setup-error-handling)" -e "(extension-name-and-version '(\"ola\" \"\"))" -e "(keep-intermediates #t)" -e "(setup-install-mode #f)" 'ola.setup'
  '/usr/local/bin/csc' -feature compiling-extension -setup-mode -k   -s -O2 -d0 -c++ -X r7rs -R r7rs -J ola.sld -R srfi-99 -L `pkg-config --libs libola` -C -Wno-write-strings
In file included from ola.cpp:11:0:
ola.cpp: In function ‘long int stub333(long int, long int, long int):
ola.cpp:154:37: error: call of overloaded ‘InitLogging(int&, int&)’ is ambiguous
 C_r=C_mk_bool(ola::InitLogging(t0,t1));
                                     ^
/usr/local/include/chicken/chicken.h:1098:38: note: in definition of macro ‘C_mk_bool’
 #define C_mk_bool(x)               ((x) ? C_SCHEME_TRUE : C_SCHEME_FALSE)
                                      ^
ola.cpp:154:37: note: candidates are:
 C_r=C_mk_bool(ola::InitLogging(t0,t1));
                                     ^
/usr/local/include/chicken/chicken.h:1098:38: note: in definition of macro ‘C_mk_bool’
 #define C_mk_bool(x)               ((x) ? C_SCHEME_TRUE : C_SCHEME_FALSE)
                                      ^
In file included from ola.cpp:14:0:
/usr/include/ola/Logging.h:231:6: note: bool ola::InitLogging(ola::log_level, ola::log_output) <near match>
 bool InitLogging(log_level level, log_output output);
      ^
/usr/include/ola/Logging.h:231:6: note:   no known conversion for argument 2 from ‘int’ to ‘ola::log_output’
/usr/include/ola/Logging.h:239:6: note: void ola::InitLogging(ola::log_level, ola::LogDestination*) <near match>
 void InitLogging(log_level level, LogDestination *destination);
      ^
/usr/include/ola/Logging.h:239:6: note:   no known conversion for argument 2 from ‘int’ to ‘ola::LogDestination*’

Error: shell command terminated with non-zero exit status 256: 'g++' 'ola.cpp' -o 'ola.o' -c  -fno-strict-aliasing -fwrapv -DHAVE_CHICKEN_CONFIG_H -DC_ENABLE_PTABLES -Os -fomit-frame-pointer -fPIC -DPIC -DC_SHARED -Wno-write-strings -I"/usr/local/include/chicken"

Error: shell command failed with nonzero exit status 256:

  '/usr/local/bin/csc' -feature compiling-extension -setup-mode -k   -s -O2 -d0 -c++ -X r7rs -R r7rs -J ola.sld -R srfi-99 -L `pkg-config --libs libola` -C -Wno-write-strings


Error: shell command terminated with nonzero exit code
17920
"'/usr/local/bin/csi' -bnq -setup-mode -e \"(require-library setup-api)\" -e \"(...

test case for binding typedef enum difficulty added by retroj on Tue May 12 18:08:49 2015


;; compile with:
;;
;;    csc -O2 -d0 -c++ bind-typedef-enum.scm -C "-Wno-write-strings"


(import chicken scheme foreign)

(use (srfi 1)
     extras
     foreigners)


#>

typedef enum {
  Foo,
  Bar,
  Baz,
  Quux
} MetasyntacticVariable;

int a_function (MetasyntacticVariable v) {
  return 0;
}

int a_function (void* p) {
  return 1;
}

<#

(define-foreign-enum-type (metasyntacticvariable int)
  (metasyntacticvariable->int int->metasyntacticvariable)
  (mv/foo Foo)
  (mv/bar Bar)
  (mv/baz Baz)
  (mv/quux Quux))

(define a_function
  (foreign-lambda int "a_function" metasyntacticvariable))

(pp (a_function 'mv/foo))