I am trying to write a dynamic module to expose some constants in the GNU Scientific Library. I thought something like this would do it.
#include <gsl/gsl_const_mksa.h>
#include "emacs-module.h"
int plugin_is_GPL_compatible;
int emacs_module_init(struct emacs_runtime *ert)
{
emacs_env *env = ert->get_environment(ert);
emacs_value defconst = env->intern(env, "defconst");
char doc[] = "Speed of light in vacuum (m/s).";
emacs_value args[] = {
env->intern(env, "GSL-CONST-MKSA-SPEED-OF-LIGHT"),
env->make_float(env, GSL_CONST_MKSA_SPEED_OF_LIGHT),
env->make_string(env, doc, sizeof doc)
};
env->funcall(env, defconst, 3, args);
// This is what allows the shared library to provide a feature
emacs_value provide = env->intern(env, "provide");
emacs_value provide_args[] = { env->intern(env, "gsl-constants") };
env->funcall(env, provide, 1, provide_args);
return 0;
}
This compiles fine with
gcc -Wall -I/usr/local/include -fPIC -c gsl-constants.c
gcc -shared -L/usr/local/include -lgsl -o gsl-constants.so gsl-constants.o
But something is not working because I get "Required feature ‘gsl-constants’ was not provided" if I try to (require 'gsl-constants).
I guess that something is wrong with the defconst part because if I comment that out, it requires fine. Does anyone know if there is another way to define constants or variables in a dynamic module?