VC7 dllimport regression problem 
Author Message
 VC7 dllimport regression problem

I've got a skeleton of a class hierarchy below that builds fine with
VC6 SP5, but gives C2491 'defn of dllimport fn not allowed' compile
errors at the marked lines on VC7 v13.0.9446.  It seems to me that
this is an erroneous error, because when I removed the definitions in
the original file, the compiler complained that they were not there
(error C4661).  Can anyone suggest a workaround (other than not to use
dllimport, I want the class defn to remain in only 1 particular DLL as
it was in VC6)?

Thanks.

------------------------
class _declspec(dllimport) ReferenceCount {

Quote:
};

template<class Base>
class _declspec(dllimport)  RefCountProxy : public ReferenceCount {
public:
  static void init_type();

Quote:
};

template<class Base>
class _declspec(dllimport)  RefCountObj : public ReferenceCount,
public Base {
public:
  static void init_type();

Quote:
};

template<class Base>   //  C2491 error here
  void RefCountProxy<Base>::init_type() {}

template<class Base>   //  C2491 error here
  void RefCountObj<Base>::init_type() {}



Thu, 22 Jul 2004 14:26:38 GMT  
 VC7 dllimport regression problem
You have to define dllexport for the DLL and dllimport for the exe that uses
the dll..


Quote:
> I've got a skeleton of a class hierarchy below that builds fine with
> VC6 SP5, but gives C2491 'defn of dllimport fn not allowed' compile
> errors at the marked lines on VC7 v13.0.9446.  It seems to me that
> this is an erroneous error, because when I removed the definitions in
> the original file, the compiler complained that they were not there
> (error C4661).  Can anyone suggest a workaround (other than not to use
> dllimport, I want the class defn to remain in only 1 particular DLL as
> it was in VC6)?

> Thanks.

> ------------------------
> class _declspec(dllimport) ReferenceCount {
> };

> template<class Base>
> class _declspec(dllimport)  RefCountProxy : public ReferenceCount {
> public:
>   static void init_type();
> };

> template<class Base>
> class _declspec(dllimport)  RefCountObj : public ReferenceCount,
> public Base {
> public:
>   static void init_type();
> };

> template<class Base>   //  C2491 error here
>   void RefCountProxy<Base>::init_type() {}

> template<class Base>   //  C2491 error here
>   void RefCountObj<Base>::init_type() {}



Fri, 23 Jul 2004 21:08:56 GMT  
 VC7 dllimport regression problem
sure, that's what I do in the original code.  The problem
is that VC7 wont compile the dllimport version.

Quote:
>-----Original Message-----
>You have to define dllexport for the DLL and dllimport

for the exe that uses
Quote:
>the dll..



>> I've got a skeleton of a class hierarchy below that
builds fine with
>> VC6 SP5, but gives C2491 'defn of dllimport fn not
allowed' compile
>> errors at the marked lines on VC7 v13.0.9446.  It
seems to me that
>> this is an erroneous error, because when I removed the
definitions in
>> the original file, the compiler complained that they
were not there
>> (error C4661).  Can anyone suggest a workaround (other
than not to use
>> dllimport, I want the class defn to remain in only 1
particular DLL as
>> it was in VC6)?

>> Thanks.

>> ------------------------
>> class _declspec(dllimport) ReferenceCount {
>> };

>> template<class Base>
>> class _declspec(dllimport)  RefCountProxy : public
ReferenceCount {
>> public:
>>   static void init_type();
>> };

>> template<class Base>
>> class _declspec(dllimport)  RefCountObj : public
ReferenceCount,
>> public Base {
>> public:
>>   static void init_type();
>> };

>> template<class Base>   //  C2491 error here
>>   void RefCountProxy<Base>::init_type() {}

>> template<class Base>   //  C2491 error here
>>   void RefCountObj<Base>::init_type() {}

>.



Sat, 24 Jul 2004 05:46:28 GMT  
 VC7 dllimport regression problem
I surprised this ever worked - we have never officially supported code like
the following:

template<typename T>
class __declspec(dllexport) X {

Quote:
};

The reason being we did not think that anyone would want to have all
specializations of a class template be dllexport or import.

The "approved" way of doing this is the following:

1) Define the template:

template<typename T>
class X {

Quote:
};

2) Explicitly instantiate the specialization you want to dllexport/dllimport

template class __declspec(dllexport) X<int>;

Note: the error message is valid - if you declare a class to be dllimport
then you cannot define and of its method outside of the class: as they are
meant to be in the DLL.

--
Jonathan Caves
Microsoft Corporation

This posting is provided "AS IS" with no warranties, and confers no rights.
You assume all risk for your use. ? 2002 Microsoft Corporation. All rights
reserved.

http://www.microsoft.com/info/cpyright.htm.

Quote:
> sure, that's what I do in the original code.  The problem
> is that VC7 wont compile the dllimport version.

> >-----Original Message-----
> >You have to define dllexport for the DLL and dllimport
> for the exe that uses
> >the dll..



> >> I've got a skeleton of a class hierarchy below that
> builds fine with
> >> VC6 SP5, but gives C2491 'defn of dllimport fn not
> allowed' compile
> >> errors at the marked lines on VC7 v13.0.9446.  It
> seems to me that
> >> this is an erroneous error, because when I removed the
> definitions in
> >> the original file, the compiler complained that they
> were not there
> >> (error C4661).  Can anyone suggest a workaround (other
> than not to use
> >> dllimport, I want the class defn to remain in only 1
> particular DLL as
> >> it was in VC6)?

> >> Thanks.

> >> ------------------------
> >> class _declspec(dllimport) ReferenceCount {
> >> };

> >> template<class Base>
> >> class _declspec(dllimport)  RefCountProxy : public
> ReferenceCount {
> >> public:
> >>   static void init_type();
> >> };

> >> template<class Base>
> >> class _declspec(dllimport)  RefCountObj : public
> ReferenceCount,
> >> public Base {
> >> public:
> >>   static void init_type();
> >> };

> >> template<class Base>   //  C2491 error here
> >>   void RefCountProxy<Base>::init_type() {}

> >> template<class Base>   //  C2491 error here
> >>   void RefCountObj<Base>::init_type() {}

> >.



Sat, 24 Jul 2004 06:15:52 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. dllimport CString problem from VC7 to VC6

2. VC7 pointer regression

3. VC7 STL regression?

4. VC7 STL regression?

5. DllImport Problem

6. Problems with DllImport

7. dllimport and link warning problem

8. Help!!! dllimport and dllexport problem

9. dllimport problem ???

10. problem using dll in aplikation Link error: "__declspec(dllimport)

11. dllimport/export problem upgrading to STLPort 4.5 (under Visual C++ 6.0)

12. problem about dllimport

 

 
Powered by phpBB® Forum Software