【发布时间】:2014-03-27 02:47:19
【问题描述】:
我目前正在开发一组用 Chicken Scheme 编写的实用程序,这是我第一次尝试在 Chicken Scheme 中编写基于多文件的程序(或一组程序),我正在在弄清楚如何正确使用附件文件中定义的代码时遇到了一些麻烦,以便在编译所有内容时,文件A中定义的代码将可以被文件B的编译形式访问。我基本上需要 Chicken Scheme 的等效于以下 C 代码:
#include "my_helper_lib.h"
int
main(void)
{
/* use definitions provided by my_helper_lib.h */
return 0;
}
我尝试过使用以下所有方法,但它们都产生了各种不寻常的错误,例如:'() 未定义,这没有意义,因为'() 只是@987654326 的另一种写作方式@。
;;; using `use`
(use "helper.scm") ;; Error: (require) cannot load extension: helper.scm
;;; using modules
;; helper.scm
(module helper (foo)
(import scheme)
(define foo (and (display "foobar") (newline))))
;; main.scm
(import helper) ;; Error: module unresolved: helper
;;; using `load`
(load helper.scm) ;; Error: unbound variable: helper.scm
(load "helper.scm") ;; Error: unbound variable: use
;; note: helper.scm contained `(use scheme)` at this point
;; using `require`
(require 'helper.scm) ;; Error: (require) cannot load extension: helper.scm
【问题讨论】:
标签: c compilation runtime-error chicken-scheme