This is the mail archive of the guile@cygnus.com mailing list for the guile project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Ian Grant <I.A.N.Grant@damtp.cam.ac.uk> writes: > What I would prefer though would be to build the postgres glue as a > shared library and have it dlopen()ed or whatever by the > ``use-module: (database postgres)'' clause. My sybase code does this, already, I guess it would benefit from some comments. Everything you need has the string _init() in it. The current module system will be abandoned at some point (I wish I knew when), so I don't know if this information is worth adding to the permanent docs, but here goes nothing. Lets assume you want to create a 'C' module named (database postgres). You need to define two functions. The first of these is run when the module system slurps in the shared library, I call it the 'pre-init' function. Here is an example of a pre-init function for your module: /* the c function name is important: it is constructed out of the */ /* module name. the pre-init function points at the init function. */ void scm_init_database_postgres_module() { scm_register_module_xxx("database postgres", (void*)scm_init_postgres); } Now you need an init function, which gets called later when your module is actually used for the first time. This two phase initialization makes it possible to use the same code from a shared library, or statically linked into a guile interpreter. void scm_init_postgres(void) { /* your real initializations go here */ } If you add a couple of printf's, you can see the order in which things happen. The one last thing to do is to put the resulting shared library somewhere on %load-path, and presto you should be off and running. Don't forget -fPIC (this caused me some problems the first time). I can fill out this discussion with more detail if that would help; let me know. -russ -- "Unfortunately the only Windows feature inspired by Emacs was size." -- Nick C. in alt.religion.emacs