[extension] load_single_library() - silent failure?

When calling load_single_library(), if the 3rd parameter, which is the name of the export factory function, is incorrect, load_single_library() will silently fail and return as if nothing went wrong. However, since the name of that function was mistyped (in my case), I had to debug into the boost.extensions library to figure out the actual source of the problem. I think this should have thrown an exception. For example, I called the function like below: factory_map fm; load_single_library( fm, "my_library.dll", "my_export_method_typo" ); And my function, as defined in the DLL source, is as follows: extern "C" void BOOST_EXTENSION_EXPORT_DECL my_export_method( boost::extensions::factory_map& fm ) { } As you can see, the string (in the first code example) is clearly mistyped/misnamed. This results in silent failure. Opinions on this would be useful.

Robert, The load_single_library method is a convenience method for a common case. In general, I recommend using a shared_library object instead. I believe this case is detailed in the latest documentation. However, you are probably right that I need to change the load_single_library function to either return a bool or throw an exception. Thanks for the heads up, and sorry about the time lost debugging. Jeremy On Thu, Jul 3, 2008 at 4:15 PM, Robert Dailey <rcdailey@gmail.com> wrote:
When calling load_single_library(), if the 3rd parameter, which is the name of the export factory function, is incorrect, load_single_library() will silently fail and return as if nothing went wrong. However, since the name of that function was mistyped (in my case), I had to debug into the boost.extensions library to figure out the actual source of the problem. I think this should have thrown an exception.
For example, I called the function like below:
factory_map fm; load_single_library( fm, "my_library.dll", "my_export_method_typo" );
And my function, as defined in the DLL source, is as follows:
extern "C" void BOOST_EXTENSION_EXPORT_DECL my_export_method( boost::extensions::factory_map& fm ) { }
As you can see, the string (in the first code example) is clearly mistyped/misnamed. This results in silent failure. Opinions on this would be useful. _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

On Thu, Jul 3, 2008 at 7:15 PM, Jeremy Pack <rostovpack@gmail.com> wrote:
Robert,
The load_single_library method is a convenience method for a common case. In general, I recommend using a shared_library object instead. I believe this case is detailed in the latest documentation.
However, you are probably right that I need to change the load_single_library function to either return a bool or throw an exception.
Thanks for the heads up, and sorry about the time lost debugging.
Jeremy
On Thu, Jul 3, 2008 at 4:15 PM, Robert Dailey <rcdailey@gmail.com> wrote:
When calling load_single_library(), if the 3rd parameter, which is the name of the export factory function, is incorrect, load_single_library() will silently fail and return as if nothing went wrong. However, since the name of that function was mistyped (in my case), I had to debug into the boost.extensions library to figure out the actual source of the problem. I think this should have thrown an exception.
For example, I called the function like below:
factory_map fm; load_single_library( fm, "my_library.dll", "my_export_method_typo" );
And my function, as defined in the DLL source, is as follows:
extern "C" void BOOST_EXTENSION_EXPORT_DECL my_export_method( boost::extensions::factory_map& fm ) { }
As you can see, the string (in the first code example) is clearly mistyped/misnamed. This results in silent failure. Opinions on this would be useful. _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
I've been reading the documentation online, which I found out later on was out of date, since some of the source examples would not compile. Is there a nightly version of your documentation online? I've been having to shift through files in the boost svn repository to look at the tutorial source. If you have this it would be helpful. No worries on the loss of time debugging, that didn't really bother me at all. I'm just offering my opinions on things as I move along to see if they could possibly help the library grow and improve. Debugging it is actually a very good learning experience, since I've been spending today learning about Boost.Extensions. So far I am very impressed with the library and it's made what I'm working on incredibly easy! Great work!
participants (2)
-
Jeremy Pack
-
Robert Dailey