DLL in C++Builder6

  • Thread starter Henrique O. Santos
  • Start date
H

Henrique O. Santos

Hi all.

I'm trying to export a class and its instance in a dll in c++builder.
My class definition in the dll project is like this:

class __declspec(dllexport) TableTest
{
// class definitions with only public functions and data fields.
};

__declspec(dllexport) TableTest Test;

-----------

In my other project in wich i use the created .dll and .lib, i have:

class __declspec(dllimport) TableTest;
__declspec(dllimport) TableTest Test;

But when i try to access any of functions or data fields from Test
(like: Test.Name) i get the following compile error:

E2315: 'Name' is not a member of 'TableTest', because the type is not
defined yet.

Thanks for any help.

Henrique.
 
V

Victor Bazarov

Henrique O. Santos said:
I'm trying to export a class and its instance in a dll in c++builder.
My class definition in the dll project is like this:

class __declspec(dllexport) TableTest
{
// class definitions with only public functions and data fields.
};

__declspec(dllexport) TableTest Test;

-----------

In my other project in wich i use the created .dll and .lib, i have:

class __declspec(dllimport) TableTest;
__declspec(dllimport) TableTest Test;

But when i try to access any of functions or data fields from Test
(like: Test.Name) i get the following compile error:

E2315: 'Name' is not a member of 'TableTest', because the type is not
defined yet.

Let's put aside all the off-topic nonsense like __declspec and such.
One rule remains in effect: in order to call a member function, the
compiler has to know that it exists, what its arguments are and what
its return value type is. You give this information to the compiler
in the form of the class definition. Your "other project" apparently
doesn't have the benefit of the class definition. How do you suppose
the compiler should be able to deal with that?

V
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,968
Messages
2,570,149
Members
46,695
Latest member
StanleyDri

Latest Threads

Top