* Updated examples (compilation flags, coding style)
git-svn-id: svn://svn.zoy.org/elk/trunk@69 55e467fa-43c5-0310-a8a2-de718669efc6
This commit is contained in:
parent
230f3fc843
commit
af3ee62078
|
@ -9,7 +9,7 @@ See constructor.cpp in this directory for compilation instructions.
|
||||||
Here is a transcript showing a test run under Linux using the
|
Here is a transcript showing a test run under Linux using the
|
||||||
GNU g++ compiler:
|
GNU g++ compiler:
|
||||||
|
|
||||||
% g++ -shared -fPIC -I/usr/include/elk class.cpp -o class.so -lelk
|
% g++ -shared -fPIC class.cpp -o class.so -lelk
|
||||||
%
|
%
|
||||||
% scheme
|
% scheme
|
||||||
> (load 'class.so)
|
> (load 'class.so)
|
||||||
|
@ -45,7 +45,7 @@ void foo::write_val(int newval) {
|
||||||
|
|
||||||
/* ---------------------------------- */
|
/* ---------------------------------- */
|
||||||
|
|
||||||
#include "scheme.h"
|
#include <elk/scheme.h>
|
||||||
|
|
||||||
struct S_Foo {
|
struct S_Foo {
|
||||||
Object tag; class foo foo;
|
Object tag; class foo foo;
|
||||||
|
|
|
@ -5,11 +5,11 @@ are invoked by Elk when loading a compiled C++ file (when exiting).
|
||||||
|
|
||||||
o Compile the shared object, for instance:
|
o Compile the shared object, for instance:
|
||||||
|
|
||||||
CC -pic -shared -I/usr/elk/include constructor.cpp -o constructor.so -lelk
|
CC -pic -shared constructor.cpp -o constructor.so -lelk
|
||||||
|
|
||||||
or:
|
or:
|
||||||
|
|
||||||
g++ -fPIC -shared -I/usr/include/elk constructor.ppc -o constructor.so -lelk
|
g++ -fPIC -shared constructor.ppc -o constructor.so -lelk
|
||||||
|
|
||||||
o Now "(load 'constructor.so)", observe the "invoking constructor" message,
|
o Now "(load 'constructor.so)", observe the "invoking constructor" message,
|
||||||
and evaluate "(test)", which should return 3. Terminate the interpreter
|
and evaluate "(test)", which should return 3. Terminate the interpreter
|
||||||
|
@ -28,7 +28,7 @@ o If static constructors don't get called when loading compiled C++ files,
|
||||||
your C++ compiler is probably using a naming convention for static
|
your C++ compiler is probably using a naming convention for static
|
||||||
constructors and destructors that is not anticipated by the current
|
constructors and destructors that is not anticipated by the current
|
||||||
version of Elk.
|
version of Elk.
|
||||||
|
|
||||||
In this case, you may want to find out what kind of names are used
|
In this case, you may want to find out what kind of names are used
|
||||||
(by applying "nm" to an object file) and add the name prefixes to
|
(by applying "nm" to an object file) and add the name prefixes to
|
||||||
the Init_Prefixes and Finit_Prefixes lists in src/stab.c in the Elk
|
the Init_Prefixes and Finit_Prefixes lists in src/stab.c in the Elk
|
||||||
|
@ -36,7 +36,7 @@ o If static constructors don't get called when loading compiled C++ files,
|
||||||
----------------------------------------------------------------------*/
|
----------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
|
||||||
#include "scheme.h"
|
#include <elk/scheme.h>
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
@ -47,7 +47,9 @@ public:
|
||||||
std::cerr << "[invoking constructor]" << std::endl;
|
std::cerr << "[invoking constructor]" << std::endl;
|
||||||
i = 3;
|
i = 3;
|
||||||
}
|
}
|
||||||
~C() { std::cerr << "[invoking destructor]" << std::endl; }
|
~C() {
|
||||||
|
std::cerr << "[invoking destructor]" << std::endl;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
C c;
|
C c;
|
||||||
|
|
Loading…
Reference in New Issue