another idea would be to allow to skip macros via some keyword :skip-macro
example patch:
--- gauche-c-wrapper-0.6.1/lib/c-wrapper/c-parser.scm 2009-08-08
16:44:52.0 +0200
+++ gauche-c-wrapper-0.6.1.new/lib/c-wrapper/c-parser.scm 2018-02-09
16:56:03.390344967 +0100
@@ -1099,7 +1099,7 @@
;;:show-define? #f))
;;(start-macro-reset!)))
-(define (parse-macro include-dirs headers options)
+(define (parse-macro include-dirs headers options skip-macro)
(unwind-protect
(guard (e (( e)
(let ((errmsg (make-error-message (condition-ref e 'message
@@ -1115,7 +1115,10 @@
(raise e
(call-with-gcc-io include-dirs headers options
(lambda (in out)
- (let ((macro-list (queue->list (macro-queue
+ (let ((macro-list (filter
+ (lambda(m)
+ (not (skip-macro (car m
+ (queue->list (macro-queue)
(for-each (lambda (macro-def)
(display (car macro-def) out)
(newline out))
@@ -1152,11 +1155,11 @@
(else
(errorf "~s can't be used for :import argument." import-cond)
-(define (c-parse include-dirs headers options import-arg export? sandbox hides)
+(define (c-parse include-dirs headers options import-arg export? sandbox hides
skip-macro)
(with-parse-context
(lambda ()
(parse-source include-dirs headers options)
- (parse-macro include-dirs headers options)
+ (parse-macro include-dirs headers options skip-macro)
(let ((export-syms
(if import-arg
--- gauche-c-wrapper-0.6.1/lib/c-wrapper.scm2009-08-08 16:44:52.0
+0200
+++ gauche-c-wrapper-0.6.1.new/lib/c-wrapper.scm2018-02-09
16:45:26.045654080 +0100
@@ -91,7 +91,8 @@
(module #t)
(export? #f)
(output #f)
- (hide-symbols '()))
+ (hide-symbols '())
+ (skip-macro (lambda(m) #f)))
(when (eq? module #t)
(set! export? #t))
(parameterize ((sandbox-module (make-sandbox curmod module)))
@@ -117,7 +118,8 @@
(lambda (expr)
(push! output-list expr))
(sandbox-module))
- hide-symbols)
+ hide-symbols
+ skip-macro)
(if output
(call-with-output-file output
(lambda (out)
@@ -154,7 +156,8 @@
(module #t)
(export? #f)
(output #f)
- (hide-symbols '()))
+ (hide-symbols '())
+ (skip-macro (lambda(m) #f)))
(cond
((compiled-lib-exist? compiled-lib)
`(begin
@@ -171,7 +174,7 @@
" ")))
`(begin
(c-ld ,ld-option)
- (c-include ,headers :option ,cpp-option :import ,import-arg :output
,output :module ,module :export? ,export? :hide-symbols ,hide-symbols)))
+ (c-include ,headers :option ,cpp-option :import ,import-arg :output
,output :module ,module :export? ,export? :hide-symbols ,hide-symbols
:skip-macro ,skip-macro)))
(define-syntax define-enum
(syntax-rules ()
--- gauche-c-wrapper-0.6.1/testsuite/cwrappertest.scm 2009-08-08
16:44:51.0 +0200
+++ gauche-c-wrapper-0.6.1.new/testsuite/cwrappertest.scm 2018-02-09
16:49:49.349893969 +0100
@@ -10,7 +10,7 @@
(test-module 'c-wrapper)
(c-load-library "./ffitest")
-(c-include "./ffitest.h")
+(c-include "./ffitest.h" :skip-macro (lambda(m) (#/^__glibc_macro_warning/ m)))
(define-syntax test-cfunc
(syntax-rules ()