
Hi, I am not much of a Windows programmer, so I have a basic question. I want to make a library that (among other stuff) defines an exception like this: #include <boost/exception/exception.hpp> namespace speedo { typedef boost::error_info<struct tag_error, unsigned> error_info; class __declspec(dllexport) exception : public boost::exception { }; } When I try to compile this, I get the following warning: c:\cygwin\home\andrej\speedo\trunk\util\exception.h(14) : warning C4275: non dll-interface class 'boost::exception' used as base for dll-interface class 'speedo::exception' C:\cygwin\home\Andrej\speedo\trunk\boost/exception/exception.hpp(47) : see declaration of 'boost::exception' c:\cygwin\home\andrej\speedo\trunk\util\exception.h(13) : see declaration of 'speedo::exception' Is this a problem, and, how do I get rid of this without changing the boost-exception lib itself? Cheers, Andrej __________________________________________________________ Not happy with your email address?. Get the one you really want - millions of new email addresses available now at Yahoo! http://uk.docs.yahoo.com/ymail/new.html

On Mon, Jul 28, 2008 at 8:36 AM, Andrej van der Zee <mavdzee@yahoo.co.uk> wrote:
Hi,
I am not much of a Windows programmer, so I have a basic question. I want to make a library that (among other stuff) defines an exception like this:
#include <boost/exception/exception.hpp>
namespace speedo {
typedef boost::error_info<struct tag_error, unsigned> error_info;
class __declspec(dllexport) exception : public boost::exception { };
}
When I try to compile this, I get the following warning:
c:\cygwin\home\andrej\speedo\trunk\util\exception.h(14) : warning C4275: non dll-interface class 'boost::exception' used as base for dll-interface class 'speedo::exception' C:\cygwin\home\Andrej\speedo\trunk\boost/exception/exception.hpp(47) : see declaration of 'boost::exception' c:\cygwin\home\andrej\speedo\trunk\util\exception.h(13) : see declaration of 'speedo::exception'
Is this a problem, and, how do I get rid of this without changing the boost-exception lib itself?
Cheers, Andrej
Try putting the __decspec modifier on each (public) method of your exception class rather than on the class itself. IIRC, that stops MSVC whinging about not having a __declspec on the base class. HTH Stuart Dootson

I usually ignored this warning. I'm not sure what can happen as the result. Peter
#include <boost/exception/exception.hpp>
namespace speedo {
typedef boost::error_info<struct tag_error, unsigned> error_info;
class __declspec(dllexport) exception : public boost::exception { };
}
When I try to compile this, I get the following warning:
c:\cygwin\home\andrej\speedo\trunk\util\exception.h(14) : warning C4275: non dll-interface class 'boost::exception' used as base for dll-interfa ce class 'speedo::exception' C:\cygwin\home\Andrej\speedo\trunk\boost/exception/exception.hpp (47) : see declaration of 'boost::exception' c:\cygwin\home\andrej\speedo\trunk\util\exception.h(13) : see de claration of 'speedo::exception'
Is this a problem, and, how do I get rid of this without changing the bo ost-exception lib itself?

#include <boost/exception/exception.hpp>
namespace speedo {
typedef boost::error_info<struct tag_error, unsigned> error_info;
class __declspec(dllexport) exception : public boost::exception { };
}
When I try to compile this, I get the following warning:
c:\cygwin\home\andrej\speedo\trunk\util\exception.h(14) : warning C4275: non
Andrej van der Zee <mavdzee <at> yahoo.co.uk> writes: dll-interface class
'boost::exception' used as base for dll-interface class 'speedo::exception' C:\cygwin\home\Andrej\speedo\trunk\boost/exception/exception.hpp (47) : see declaration of 'boost::exception' c:\cygwin\home\andrej\speedo\trunk\util\exception.h(13) : see declaration of 'speedo::exception'
Is this a problem, and, how do I get rid of this without changing the boost- exception lib itself?
The exported attribute indicates that all functions from the class are exported. The warning is that you can potentially call a non exported function from the base class, e.g.: struct public Base { void Foo1(); //impl. in cpp }; struct __declspec(dllexport) Derived : public Base { void Foo2(); //impl. in cpp }; void Foo() { Derived d; d.Foo1(); //error, but at least a linker error d.Foo2(); } wkr, me

You can ignore 4275 for pure header template classes. The only risk is if you have different definitions for the template or any of its parameters (which is bad for other reasons, which are likely to trip you up before 4275 manifests). You could try this - In the header: template struct __declspec(dllexport) boost::error_info<struct tag_error, unsigned>; // at file scope In a library source file: template struct boost::error_info<struct tag_error, unsigned>; // at file scope You may need to use "class" instead of "struct", depends on how error_info is defined. According to Microsoft documentation, this will result in the implementation of the fully specified template residing in the library. I have tried it and the code that depends on it works, but it's unclear if it's really instantiating the template in the library. At 02:36 AM 7/28/2008, you wrote:
I am not much of a Windows programmer, so I have a basic question. I want to make a library that (among other stuff) defines an exception like this:
#include <boost/exception/exception.hpp>
namespace speedo {
typedef boost::error_info<struct tag_error, unsigned> error_info;
class __declspec(dllexport) exception : public boost::exception { };
}
When I try to compile this, I get the following warning:
c:\cygwin\home\andrej\speedo\trunk\util\exception.h(14) : warning C4275: non dll-interface class 'boost::exception' used as base for dll-interface class 'speedo::exception'
participants (5)
-
Alan M. Carroll
-
Andrej van der Zee
-
gast128
-
peter_foelscheļ¼ agilent.com
-
Stuart Dootson