Boost logo

Boost :

From: Robert Ramey (ramey_at_[hidden])
Date: 2004-09-24 14:29:03


Howard Hinnant wrote:

>How are clients (who can view only parsers.hpp) to know that:

>template<>
> basic_parsed_options<char>
> parse_config_file(std::basic_istream<char>& is,
> const options_description& desc);

>is a function to be imported from a DLL? Does adding to parsers.hpp
>something like:

>template<> __declspec(dllimport)
> basic_parsed_options<char>
> parse_config_file(std::basic_istream<char>& is,
> const options_description& desc);

>help?

I believe that most of the failures of the serialization library with
toolset are due to similar problems.

There we have

Template<class T>
Struct A : public Abase {
        A(const char * name){
                //register this instance in a global table
                Register(this, name);
        }
        // static instance to be created at pre-runtime
        Static A instance;
        do_something();
};

Template<class T>
Static A A::instance("T");

So that later when

// lookup T
Abase *ab = std::find("T")
Ab->do_something();

It seems that the compiler optimizes away the code since its never
explicitly called. An attempt to find the class through its name fails, the
code isn't found, and the test fails.

I've attempted to force instantiation of the code through various means such
as dllexport and others. This solved the problem for other compilers but
I've been unable to get it to work for Metrowerks. Alas my, 15 trial
license expired so it will have to remain as it is until someone with an
interest in this compiler decides they want to spend some time on this.

Robert Ramey
 


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk