Back to index

plt-scheme  4.2.1
hello.c
Go to the documentation of this file.
00001 /* 
00002    MzScheme extension example that returns the string "Hello, world!"
00003    when loaded.
00004 
00005    For 3m, compile with:
00006      mzc --xform hello.c
00007      mzc --3m --cc hello.3m.c
00008      mzc --3m --ld hello.so hello.o
00009    And load with
00010      (load-extension "hello.so") ; or "hello.dylib" for Mac OS X
00011                                  ; or "hello.dll" for Windows
00012 
00013    For CGC, compile with:
00014      mzc --cgc --cc hello.c
00015      mzc --cgc --ld hello.so hello.o
00016    And load with
00017      (load-extension "hello.so") ; or "hello.dylib" for Mac OS X
00018                                  ; or "hello.dll" for Windows
00019 
00020 */
00021 
00022 #include "escheme.h"
00023 
00024 Scheme_Object *scheme_reload(Scheme_Env *env)
00025 {
00026   /* When the extension is loaded, return a Scheme string: */
00027   return scheme_make_utf8_string("Hello, world!");
00028 }
00029 
00030 Scheme_Object *scheme_initialize(Scheme_Env *env)
00031 {
00032   /* First load is same as every load: */
00033   return scheme_reload(env);
00034 }
00035 
00036 Scheme_Object *scheme_module_name()
00037 {
00038   /* This extension doesn't define a module: */
00039   return scheme_false;
00040 }