Click here to Skip to main content
16,007,277 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Confused: CButton's DrawItem and onclicked Pin
Paolo Messina27-Jan-03 14:09
professionalPaolo Messina27-Jan-03 14:09 
GeneralRe: Confused: CButton's DrawItem and onclicked Pin
JohnnyG28-Jan-03 3:04
JohnnyG28-Jan-03 3:04 
GeneralRe: Confused: CButton's DrawItem and onclicked Pin
Paolo Messina28-Jan-03 3:34
professionalPaolo Messina28-Jan-03 3:34 
GeneralRe: Confused: CButton's DrawItem and onclicked Pin
JohnnyG28-Jan-03 6:52
JohnnyG28-Jan-03 6:52 
GeneralRe: Confused: CButton's DrawItem and onclicked Pin
Paolo Messina29-Jan-03 0:33
professionalPaolo Messina29-Jan-03 0:33 
GeneralC++ DLL usage in VC7 Pin
Jim Crafton27-Jan-03 7:29
Jim Crafton27-Jan-03 7:29 
GeneralRe: C++ DLL usage in VC7 Pin
Joe Woodbury27-Jan-03 7:56
professionalJoe Woodbury27-Jan-03 7:56 
GeneralRe: C++ DLL usage in VC7 Pin
Mike Nordell27-Jan-03 9:16
Mike Nordell27-Jan-03 9:16 
It depends.

If you export a C++ class, it would be exported according to the compilers name-mangling scheme. VC6 and VC7 have different name mangling. This could make it impossible for code compiled by one compiler to even find the mangled and exported names exported from code compiled with another compiler.

If you'd want debug info your also in for a treat since the debug format again changed (seems Microsoft can never get this right).

Depending on what memory management you use, and what dependencies you have from the DLL, it could also make it impossible.

To sum up; using a VC6 DLL (that exports C++ classes) from a VC7 app would have greater chance of success than the other way around, but I wouldn't expect any of these scenarios to work - there's just too much unspecified (and most certainly undocumented) binary incompatibilities.

The following are the only two ways around this that I'm aware of:

1. Export only a C interface that internally in the DLL uses C++ classes (lots of casting, and cumbersome). Example (modulo proprietary keywords):

For a fictious class "foo", defined as

class foo
{
    foo(int n);
    ~foo();
    int do_something(int n);
};

export the C functions

struct foo_t* foo_create(int n)
{
    return (foo_t*)new (std::nothrow) foo(n);
}

void foo_destroy(struct foo_t* p)
{
    delete (foo*)p;
}

int foo_do_something(struct foo_t* p, int n)
{
    foo* pFoo = (foo*)p;
    return pFoo->do_something(n);
}

Well, you get the idea.


2. Export factory functions (with C linkage) that returns pointers to interface classes that only have virtual functions. This resembles the way COM works, though you would of course not have to implement the COM deficiencies.

++luck;
GeneralWorker thread + memory leak.. Pin
RobJones27-Jan-03 7:01
RobJones27-Jan-03 7:01 
GeneralRe: Worker thread + memory leak.. Pin
Chris Meech27-Jan-03 7:35
Chris Meech27-Jan-03 7:35 
GeneralRe: Worker thread + memory leak.. Pin
RobJones27-Jan-03 7:51
RobJones27-Jan-03 7:51 
GeneralRe: Worker thread + memory leak.. Pin
Chris Meech27-Jan-03 7:56
Chris Meech27-Jan-03 7:56 
GeneralRe: Worker thread + memory leak.. Pin
RobJones27-Jan-03 8:06
RobJones27-Jan-03 8:06 
GeneralRe: Worker thread + memory leak.. Pin
Joaquín M López Muñoz27-Jan-03 8:05
Joaquín M López Muñoz27-Jan-03 8:05 
GeneralRe: Worker thread + memory leak.. Pin
RobJones27-Jan-03 9:38
RobJones27-Jan-03 9:38 
GeneralRe: Worker thread + memory leak.. Pin
Joaquín M López Muñoz27-Jan-03 9:44
Joaquín M López Muñoz27-Jan-03 9:44 
Generalerror C2712: Cannot use __try in functions that require object unwinding Pin
Joan M27-Jan-03 6:30
professionalJoan M27-Jan-03 6:30 
GeneralRe: error C2712: Cannot use __try in functions that require object unwinding Pin
Chris Meech27-Jan-03 7:43
Chris Meech27-Jan-03 7:43 
GeneralRe: error C2712: Cannot use __try in functions that require object unwinding Pin
Joan M27-Jan-03 8:32
professionalJoan M27-Jan-03 8:32 
GeneralRe: error C2712: Cannot use __try in functions that require object unwinding Pin
Mike Nordell27-Jan-03 9:20
Mike Nordell27-Jan-03 9:20 
GeneralRe: error C2712: Cannot use __try in functions that require object unwinding Pin
Joaquín M López Muñoz27-Jan-03 9:16
Joaquín M López Muñoz27-Jan-03 9:16 
GeneralRe: error C2712: Cannot use __try in functions that require object unwinding Pin
Joan M28-Jan-03 21:12
professionalJoan M28-Jan-03 21:12 
GeneralRe: error C2712: Cannot use __try in functions that require object unwinding Pin
Joaquín M López Muñoz28-Jan-03 21:32
Joaquín M López Muñoz28-Jan-03 21:32 
GeneralRe: error C2712: Cannot use __try in functions that require object unwinding Pin
Joan M28-Jan-03 21:37
professionalJoan M28-Jan-03 21:37 
GeneralRe: error C2712: Cannot use __try in functions that require object unwinding Pin
Joan M28-Jan-03 22:33
professionalJoan M28-Jan-03 22:33 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.