From af3ee6207833ead2c7a0c44513c8e846bcf3b464 Mon Sep 17 00:00:00 2001 From: sam Date: Tue, 2 Sep 2003 23:23:17 +0000 Subject: [PATCH] * Updated examples (compilation flags, coding style) git-svn-id: svn://svn.zoy.org/elk/trunk@69 55e467fa-43c5-0310-a8a2-de718669efc6 --- examples/c++/class.cpp | 4 ++-- examples/c++/constructor.cpp | 12 +++++++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/examples/c++/class.cpp b/examples/c++/class.cpp index fd1ce83..9a82a96 100644 --- a/examples/c++/class.cpp +++ b/examples/c++/class.cpp @@ -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 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 > (load 'class.so) @@ -45,7 +45,7 @@ void foo::write_val(int newval) { /* ---------------------------------- */ -#include "scheme.h" +#include struct S_Foo { Object tag; class foo foo; diff --git a/examples/c++/constructor.cpp b/examples/c++/constructor.cpp index 3f9b91e..c571294 100644 --- a/examples/c++/constructor.cpp +++ b/examples/c++/constructor.cpp @@ -5,11 +5,11 @@ are invoked by Elk when loading a compiled C++ file (when exiting). 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: - 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, 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 constructors and destructors that is not anticipated by the current version of Elk. - + 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 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 #include @@ -47,7 +47,9 @@ public: std::cerr << "[invoking constructor]" << std::endl; i = 3; } - ~C() { std::cerr << "[invoking destructor]" << std::endl; } + ~C() { + std::cerr << "[invoking destructor]" << std::endl; + } }; C c;