Hi all,
I wonder whether we could add c++ command in .mod file. nrnivmodl will first convert .mod file into .c file, and then compile the .c file using gcc. However, I wonder how to compile the .c file using g++, in which case we can add c++ code in the .mod file between VERBATIM and ENDVERBATIM.
Zedong
Whether it is possible to insert c++ in .mod file
Re: Whether it is possible to insert c++ in .mod file
You cannot put c++ code in mod file VERBATIM blocks. However you can build a c++ library and when you run nrnivmodl give it the option
nrnivmodl -loadflags='libmylibrary.so'
or perhaps ...='-L. -lmylibrary'
or perhaps ...='libmylibary.a'
depending on how you linked your library. Anyway, the functions and variables available from your library should have c access via the idiom
extern "C" {
// C prototypes of what you want to have available to the mod file
}
then in a mod file you can use
VERBATIM
// use any of the extern "C" prototypes defined in your libarry
ENDVERBATIM
nrnivmodl -loadflags='libmylibrary.so'
or perhaps ...='-L. -lmylibrary'
or perhaps ...='libmylibary.a'
depending on how you linked your library. Anyway, the functions and variables available from your library should have c access via the idiom
extern "C" {
// C prototypes of what you want to have available to the mod file
}
then in a mod file you can use
VERBATIM
// use any of the extern "C" prototypes defined in your libarry
ENDVERBATIM
Re: Whether it is possible to insert c++ in .mod file
Thank you. In this way, a large amount of c++ libraries will be available to neuron