I'm not entirely sure that I follow, but if you're writing these extension functions in C++, I believe you'll need to wrap their prototypes in an extern(C) { ... } block so that they'll be given un-mangled names for the linker to use.
On Thu, Feb 6, 2014 at 4:56 PM, Cody Eilar <cody.ei...@gmail.com> wrote: > I understand that, the issue is that I have to provide three functions that > are not static so that I can make my c++ code known to scheme. Those > functions are: > > scheme_reload(Scheme_Env *env) > scheme_initialize(Scheme_Env *env) > scheme_module_name() > > Each one of these functions are known to the linker. Inside the Foo_ext.cpp > file, I have these three functions implemented. But in order to use > Bar_ext.cpp I have to implement them as well, which means I have multiple > declarations to the same function. So my Bar_ext.cpp file would Ideally look > something like this: > > Bar_ext.cpp > scheme_reload(Scheme_Env *env) > { > /* Bar _ext reload stuff */ > Foo_ext.scheme_reload(env) > } > > Currently, the only way I see to solve this is to use a bunch of ifdefs, but > I was curious if there was a more elegant solution. > > Thanks! > > On Thu, Feb 6, 2014 at 2:48 AM, David T. Pierson <d...@mindstory.com> wrote: >> >> On Wed, Feb 05, 2014 at 02:16:54PM -1000, Cody Eilar wrote: >> > > But what I really want is: >> > > >> > > Foo_ext.h: >> > > >> > > func1_racket_ext() { /*... do racket stuff and run func1() */} >> > > >> > > /* Scheme initializes etc... */ >> > > >> > > >> > > Bar_ext.cpp: >> > > #include "Foo_ext.h" >> > > >> > > func2_racket_ext() {/* ... do more racket stuff and run func2() /*} >> >> Disclaimer: I know nothing about Racket extensions. >> >> In C++, if you want to be able to call a function from multiple .cpp >> files, you typically put the *declaration* in a header: >> >> void func1_ext(void); >> >> The definition would still go in a .cpp file: >> >> void func1_ext(void) >> { >> /*...*/ >> } >> >> You typically only put the definition in a header if you want to make an >> inline function. It doesn't seem like you want an inline function here. >> >> Does that help? >> >> David > > > > ____________________ > Racket Users list: > http://lists.racket-lang.org/users > ____________________ Racket Users list: http://lists.racket-lang.org/users