?
Solved

DLL in C++ classes

Posted on 1997-03-01
2
Medium Priority
?
233 Views
Last Modified: 2010-04-10
How to declare member function in def file of class ?

Declaretion as dll_name.class_name.function_name doesn't
correct.
0
Comment
Question by:a121496
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 3

Expert Comment

by:os012897
ID: 1162125
Can you be a bit more specific on what compiler you are using??

Regards,

         os

0
 

Accepted Solution

by:
pangofil earned 150 total points
ID: 1162126
It depends on the compiler You are using :
each one has his own naming convention.

But You can declare whole class as __export
and leave DEF file default.

#ifdef __DLL__
#define MYCLASSDEC __export
#else
#define MYCLASSDEC __import
#endif

class MYCALSSDEC MyClass
 {
   .....

 } ;

After linking DLL, make LIB file for it ( by IMPLIB utility ) and link LIB file to EXE You are callin DLL from.

It works for BC++ & VC++

Another way to do it :

Make outclass function, what calls class memeber function :

extern "C"
{
 int FAR PASCAL __export MyCallFunc ( ... )
  {
    return my_class.MemeberFunc ( ... ) ;
  }
}

MyCallFunc can be defined as EXPORT in DEF file.

Hope, it helps.
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
Suggested Courses

719 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question