Hello,
I have some trouble using boost::extension and boost::optional together in a
project (MSVC 7.1). The compiler complains that boost::get is not an element of
extensions::shared_library. Without the optional.hpp header everything works
fine. It seems the for some reason the macro
BOOST_EXTENSION_SHARED_LIBRARY_GET_FUNCTION isn't valid when
shared_library.get<>() is called but I can't find out why.
A small code snippet that reproduces the error
file: test_extension_and_optional.cpp
#include
Hi, it seems that the problem concerns a specific compiler bug in microsoft compilers <= 13.10.6030 (MSVC 7.1). The MSVC8 and g++ (4.1.2) compilers are able to build the code without errors.
#include
// included for some reason #include #include // load_single_library void loadExtension () { boost::extensions::factory_map fm; // we don't need the following line to produce the compiler error //boost::extensions::load_single_library(fm, ".", "external_function_name"); }
Any ideas how to get it to work with the good old Visual Studio 2003? -- David Matz ---------------------------- Software Developer Spatial View GmbH
David Matz wrote:
it seems that the problem concerns a specific compiler bug in microsoft compilers <= 13.10.6030 (MSVC 7.1).
The MSVC8 and g++ (4.1.2) compilers are able to build the code without errors.
#include
// included for some reason #include #include // load_single_library void loadExtension () { boost::extensions::factory_map fm; // we don't need the following line to produce the compiler error // ... }
Any ideas how to get it to work with the good old Visual Studio 2003?
Hmmm... We don't even need to include optional.hpp! The following gets
me the very same compile error, on MSVC 7.1:
//////////////////////////////////////////////////
namespace boost {
template<class T> class foo ;
template<class T> void get ( foo<T>* );
}
#include
Good question. Since I don't have that compiler, I've been unable to
reproduce it.
Is this: error: error C2039: 'boost::get': Ist kein Element von
'boost::extensions::shared_library'.
The only error that you see?
Please add the command line option /P to your build - this will output the
preprocessed version of your file test_extension_and_optional.cpp. Then send
this to me - I might be able to figure out what is going on. It looks like
one of the preprocessor macros used by Boost.PreProcessor isn't working - I
do have some ideas about what may cause the problem.
See: http://support.microsoft.com/kb/134650
What happens when you move boost/optional.hpp after the extension headers?
Jeremy
On Fri, Apr 18, 2008 at 8:01 AM, David Matz
Hi,
it seems that the problem concerns a specific compiler bug in microsoft compilers <= 13.10.6030 (MSVC 7.1).
The MSVC8 and g++ (4.1.2) compilers are able to build the code without errors.
#include
// included for some reason #include
#include // load_single_library void loadExtension () { boost::extensions::factory_map fm; // we don't need the following line to produce the compiler error //boost::extensions::load_single_library(fm, ".", "external_function_name"); }
Any ideas how to get it to work with the good old Visual Studio 2003?
-- David Matz ---------------------------- Software Developer Spatial View GmbH
David Matz wrote:
error: error C2039: 'boost::get': Ist kein Element von 'boost::extensions::shared_library'
Jeremy Pack wrote:
Please add the command line option /P to your build - this will output the preprocessed version of your file test_extension_and_optional.cpp. Then send this to me - I might be able to figure out what is going on. It looks like one of the preprocessor macros used by Boost.PreProcessor isn't working
It seems to me that the compile error isn't caused by Boost.PreProcessor.
Actually I think I've found a workaround: Explicitly qualify the
shared_library::get member function call in extension/convenience.hpp (line 29),
(by adding the class name, "shared_library::") and the MSVC 7.1 error message
disappears!
HTH, Niels
PS Here's the patch:
Index: convenience.hpp
===================================================================
--- convenience.hpp (revision 44584)
+++ convenience.hpp (working copy)
@@ -26,7 +26,7 @@
return;
}
void (*func)(factory_map &) =
- lib.get
Thanks! That looks like it ought to fix it.
I updated the Sandbox with the proposed fix, and was able to successfully
build and run the tests and examples on MSVC 9 and GCC 4. Please let me know
if that fixes the issue for MSVC 7.1.
Jeremy
On Sat, Apr 19, 2008 at 9:20 AM, Niels Dekker - mail address until
2008-12-31
David Matz wrote:
error: error C2039: 'boost::get': Ist kein Element von 'boost::extensions::shared_library'
Jeremy Pack wrote:
Please add the command line option /P to your build - this will output the preprocessed version of your file test_extension_and_optional.cpp. Then send this to me - I might be able to figure out what is going on. It looks like one of the preprocessor macros used by Boost.PreProcessor isn't working
It seems to me that the compile error isn't caused by Boost.PreProcessor. Actually I think I've found a workaround: Explicitly qualify the shared_library::get member function call in extension/convenience.hpp (line 29), (by adding the class name, "shared_library::") and the MSVC 7.1 error message disappears!
HTH, Niels
PS Here's the patch:
Index: convenience.hpp
===================================================================
--- convenience.hpp (revision 44584)
+++ convenience.hpp (working copy)
@@ -26,7 +26,7 @@
return; } void (*func)(factory_map &) = - lib.get
(external_function_name); + lib.shared_library::get (external_function_name); if (!func) { return;
Jeremy Pack wrote:
I updated the Sandbox with the proposed fix [...] Please let me know if that fixes the issue for MSVC 7.1.
I definitely think so (but hopefully David Matz can confirm this!) FYI, if you don't have access to MSVC 7.1, you can still reproduce the compile error detected by David, by copy-n-pasting the following to www.dinkumware.com/exam (Select "VC++ v7.1/C++" from the combo box.) //////////////////////////////////////////////////////////// namespace boost { template<class T> class foo ; template<class T> void get ( foo<T>* ); } namespace boost{ namespace extensions{ class shared_library { public: template <class ReturnValue> ReturnValue (*get())() { return 0; } }; void bar(shared_library & lib) { void (*func)() = lib.get<void>(); } } } int main() { return 0; } //////////////////////////////////////////////////////////// I don't know if this is a "known issue" of MSVC 7.1, though... Kind regards, Niels
Thank you guys, the patch from Niels solved the problem! A good hint. I run in another problem when multiple files inside a project include the extension headers. The operators in typeinfo.hpp are compiled into different object files which produces errors at link time. To solve that I declared these functions as inline see patch below. Index: typeinfo.hpp =================================================================== --- typeinfo.hpp 2008-04-14 15:18:38.000000000 +0200 +++ typeinfo_mod.hpp 2008-04-14 16:04:28.000000000 +0200 @@ -42,17 +42,17 @@ #if defined(__APPLE__) || defined(__GNUC__) || defined(BOOST_EXTENSION_FORCE_FAST_TYPEINFO) namespace boost { namespace extensions { -bool operator<(const default_type_info& first, +inline bool operator<(const default_type_info& first, const default_type_info& second) { return &first.type < &second.type; } -bool operator==(const default_type_info& first, +inline bool operator==(const default_type_info& first, const default_type_info& second) { return &first.type == &second.type; } -bool operator>(const default_type_info& first, +inline bool operator>(const default_type_info& first, const default_type_info& second) { return &first.type > &second.type; } @@ -61,17 +61,17 @@ #if defined(_WIN32) || defined(__WIN32__) || defined(WIN32) #include <string> namespace boost { namespace extensions { -bool operator<(const default_type_info& first, +inline bool operator<(const default_type_info& first, const default_type_info& second) { return std::strcmp(first.type.raw_name(), second.type.raw_name()) < 0; } -bool operator==(const default_type_info& first, +inline bool operator==(const default_type_info& first, const default_type_info& second) { return std::strcmp(first.type.raw_name(), second.type.raw_name()) == 0; } -bool operator>(const default_type_info& first, +inline bool operator>(const default_type_info& first, const default_type_info& second) { return std::strcmp(first.type.raw_name(), second.type.raw_name()) > 0; } @@ -80,17 +80,17 @@ #else // OTHER OS #include <string> namespace boost { namespace extensions { -bool operator<(const default_type_info& first, +inline bool operator<(const default_type_info& first, const default_type_info& second) { return std::strcmp(first.type.name(), second.type.name()) < 0; } -bool operator==(const default_type_info& first, +inline bool operator==(const default_type_info& first, const default_type_info& second) { return std::strcmp(first.type.name(), second.type.name()) == 0; } -bool operator>(const default_type_info& first, +inline bool operator>(const default_type_info& first, const default_type_info& second) { return std::strcmp(first.type.name(), second.type.name()) > 0; } Jeremy Pack wrote:
Thanks! That looks like it ought to fix it.
I updated the Sandbox with the proposed fix, and was able to successfully build and run the tests and examples on MSVC 9 and GCC 4. Please let me know if that fixes the issue for MSVC 7.1.
Jeremy
On Sat, Apr 19, 2008 at 9:20 AM, Niels Dekker - mail address until 2008-12-31
wrote: David Matz wrote:
error: error C2039: 'boost::get': Ist kein Element von 'boost::extensions::shared_library' Jeremy Pack wrote: Please add the command line option /P to your build - this will output the preprocessed version of your file test_extension_and_optional.cpp. Then send this to me - I might be able to figure out what is going on. It looks like one of the preprocessor macros used by Boost.PreProcessor isn't working It seems to me that the compile error isn't caused by Boost.PreProcessor. Actually I think I've found a workaround: Explicitly qualify the shared_library::get member function call in extension/convenience.hpp (line 29), (by adding the class name, "shared_library::") and the MSVC 7.1 error message disappears!
HTH, Niels
PS Here's the patch:
Index: convenience.hpp
===================================================================
--- convenience.hpp (revision 44584)
+++ convenience.hpp (working copy)
@@ -26,7 +26,7 @@
return; } void (*func)(factory_map &) = - lib.get
(external_function_name); + lib.shared_library::get (external_function_name); if (!func) { return;
-- David Matz ---------------------------- Spatial View GmbH mail: david.matz@spatialview.com site: www.spatialview.com
David and Niels,
Thanks!
I've incorporated those fixes, as well as a few readability improvements.
Please let me know if you have any other problems (or even feature
requests).
Jeremy
On Tue, Apr 22, 2008 at 12:22 AM, David Matz
Thank you guys,
the patch from Niels solved the problem! A good hint.
I run in another problem when multiple files inside a project include the extension headers. The operators in typeinfo.hpp are compiled into different object files which produces errors at link time. To solve that I declared these functions as inline see patch below.
Index: typeinfo.hpp
=================================================================== --- typeinfo.hpp 2008-04-14 15:18:38.000000000 +0200 +++ typeinfo_mod.hpp 2008-04-14 16:04:28.000000000 +0200 @@ -42,17 +42,17 @@ #if defined(__APPLE__) || defined(__GNUC__) || defined(BOOST_EXTENSION_FORCE_FAST_TYPEINFO) namespace boost { namespace extensions { -bool operator<(const default_type_info& first, +inline bool operator<(const default_type_info& first, const default_type_info& second) { return &first.type < &second.type; }
-bool operator==(const default_type_info& first, +inline bool operator==(const default_type_info& first, const default_type_info& second) { return &first.type == &second.type; }
-bool operator>(const default_type_info& first, +inline bool operator>(const default_type_info& first, const default_type_info& second) { return &first.type > &second.type; } @@ -61,17 +61,17 @@ #if defined(_WIN32) || defined(__WIN32__) || defined(WIN32) #include <string> namespace boost { namespace extensions { -bool operator<(const default_type_info& first, +inline bool operator<(const default_type_info& first, const default_type_info& second) { return std::strcmp(first.type.raw_name(), second.type.raw_name()) < 0; }
-bool operator==(const default_type_info& first, +inline bool operator==(const default_type_info& first, const default_type_info& second) { return std::strcmp(first.type.raw_name(), second.type.raw_name()) == 0; }
-bool operator>(const default_type_info& first, +inline bool operator>(const default_type_info& first, const default_type_info& second) { return std::strcmp(first.type.raw_name(), second.type.raw_name()) > 0; } @@ -80,17 +80,17 @@ #else // OTHER OS #include <string> namespace boost { namespace extensions { -bool operator<(const default_type_info& first, +inline bool operator<(const default_type_info& first, const default_type_info& second) { return std::strcmp(first.type.name(), second.type.name()) < 0; }
-bool operator==(const default_type_info& first, +inline bool operator==(const default_type_info& first, const default_type_info& second) { return std::strcmp(first.type.name(), second.type.name()) == 0; }
-bool operator>(const default_type_info& first, +inline bool operator>(const default_type_info& first, const default_type_info& second) { return std::strcmp(first.type.name(), second.type.name()) > 0;
}
Jeremy Pack wrote:
Thanks! That looks like it ought to fix it.
I updated the Sandbox with the proposed fix, and was able to successfully build and run the tests and examples on MSVC 9 and GCC 4. Please let me know if that fixes the issue for MSVC 7.1.
Jeremy
On Sat, Apr 19, 2008 at 9:20 AM, Niels Dekker - mail address until 2008-12-31
wrote: David Matz wrote:
error: error C2039: 'boost::get': Ist kein Element von 'boost::extensions::shared_library'
Jeremy Pack wrote:
Please add the command line option /P to your build - this will output the preprocessed version of your file test_extension_and_optional.cpp. Then send this to me - I might be able to figure out what is going on. It looks like one of the preprocessor macros used by Boost.PreProcessor isn't working
It seems to me that the compile error isn't caused by Boost.PreProcessor. Actually I think I've found a workaround: Explicitly qualify the shared_library::get member function call in extension/convenience.hpp (line 29), (by adding the class name, "shared_library::") and the MSVC 7.1 error message disappears!
HTH, Niels
PS Here's the patch:
Index: convenience.hpp
===================================================================
--- convenience.hpp (revision 44584)
+++ convenience.hpp (working copy)
@@ -26,7 +26,7 @@
return; } void (*func)(factory_map &) = - lib.get
(external_function_name); + lib.shared_library::get (external_function_name); if (!func) { return; -- David Matz ---------------------------- Spatial View GmbH
mail: david.matz@spatialview.com site: www.spatialview.com
participants (3)
-
David Matz
-
Jeremy Pack
-
Niels Dekker - mail address until 2008-12-31