help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

using STL in .oct files


From: Nimrod Mesika
Subject: using STL in .oct files
Date: Sat, 12 Aug 2000 21:11:55 +0300
User-agent: Mutt/1.2i

I'm trying to write an extension (an .oct file) for octave and 
having some problems with using STL (globals and class static
variables, specifically).

For example, the following code does *not* work:

// gg.cc - just an example
#include <algorithm>
#include <iostream>
#include <string>
#include <map>

#include <octave-2.1.30/config.h>
#include <octave/defun-dld.h>
#include <octave/error.h>
#include <octave/oct-obj.h>
#include <octave/pager.h>

map<string, long> directory;
DEFUN_DLD (gg, args, ,"gg(str)ŠÜn")
{

    directory["Bogart"] = 1234567;
    directory["Bacall"] = 9876543;
        
    string name = args(0).string_value();

    if (directory.find(name) != directory.end()) 
        octave_stdout << "The phone number for " << name
        << " is " << directory[name] << "ŠÜn";

    return octave_value();
}



To compile this code I removed the -fno-implicit-templates from
mkoctfile (otherwise I get linker errors when the map object
is instantiated).

The code works when `map<..> directory' is declared automatic (local
to gg). When it is declared global - octave coredumps.

This is just to illustrate my point. I get similar behavior when
declaring a new class with a static class member (essentially a
global variable).

Any explanations? Oh and why is -fno-implicit-templates in octave's
mkoctfile at all?

p.s. this is on FreeBSD 4.1 and gcc 2.95.2 19991024 (release)

-- 
Nimrod.
http://www.geocities.com/rodd_27



-----------------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.che.wisc.edu/octave/octave.html
How to fund new projects:  http://www.che.wisc.edu/octave/funding.html
Subscription information:  http://www.che.wisc.edu/octave/archive.html
-----------------------------------------------------------------------



reply via email to

[Prev in Thread] Current Thread [Next in Thread]