From octave-maintainers-request at bevo dot che dot wisc dot edu Thu Nov 20 22:57:23 2003 Subject: accessing user-defined types from C++ From: pkienzle at users dot sourceforge dot net To: octave-maintainers mailing list Date: Fri, 21 Nov 2003 00:00:19 -0000 While we are on the topic of the type system, I've been playing with methods for accessing sparse types from functions outside sparse.oct. Curiously enough, if I define the two oct-files: hello.cc: ====== #include void world(void) { octave_stdout << "world" << std::endl; } DEFUN_DLD(hello,args,nargout,"hello") { octave_stdout << "hello" << std::endl; return octave_value_list(); } world.cc: ======= #include DEFUN_DLD(world,args,nargout,"world") { void world(void); world(); return octave_value_list(); } everything works as expected: octave:1> hello hello octave:2> world world Things won't be quite so easy on windows methinks because I will need to link world.oct directly against hello.oct. I haven't tried that yet, but it will certainly complicate the build system for octave-forge. Anyone have a better how I can write an independent DLD function which accesses data from the sparse type? Right now the built-in types occupy a privileged place by virtue of having methods in the octave_value base class to access them. BTW, octave 2.1.51 fails on Linux if I do things in the other order, crashing octave in the process: octave:1> world octave: relocation error: /home/pkienzle/prog/octave/crosslink/world.oct: undefined symbol: _Z5worldv [crosslink]# Paul Kienzle pkienzle at users dot sf dot net