Advertisement

Declarations and Decortions in DLL

Started by August 08, 2000 08:29 PM
7 comments, last by ranxact 24 years, 4 months ago
I am writing a DLL and I need to overload some functions, however, I am getting errors because the compiler is making the functions _cdecl. Now, these functions are local (not exported), therefore why are they _cdecl ? and how can i use c++ naming decorations so i can overload the functions?? The online help i found only says how to go from c++ -> c .. not back.. (Win98 MSVC++6) Thanx, RanXacT
RanXact@yahoo.com
I think you can just override the default compiler calling convention by just declaring the offending functions as whatever you want. To change it for the entire project, go to project -> settings -> c/c++ -> code generation -> calling convention and change it to whatever you want.


JS
http://www.thepeel.com/void
JShttp://www.thepeel.com/void
Advertisement
Although that is a good idea, JS,the problem remains, because those options are :

_stdcall (PASCAL) only appends the size of the arguments
_fastcall .. does the same...
_cdecl .. is what i am on ..

C++ uses a different method and appends a TON of garbage at the end of the function name.. (they call it function decorations) this garbage records the types of the arguments instead of the just sizes so that such overloading as this would be possible

void * func(int *, int);
void * func(char *, int); // both have same size arguments *error*

Now, how can i go back to C++ decorations, what is the keyword or secret passcode or whatever it is called... \

_C++ ?

Thanx
RanXacT
RanXact@yahoo.com
quote: Original post by ranxact


I am writing a DLL and I need to overload some functions, however, I am getting errors because the compiler is making the functions _cdecl.

Now, these functions are local (not exported), therefore why are they _cdecl ? and how can i use c++ naming decorations so i can overload the functions??

The online help i found only says how to go from c++ -> c .. not back..

(Win98 MSVC++6)

Thanx,
RanXacT



Hi,

what i don''t understand is why you are exporting C++ functions.
If you would put them as (static) members into a class, and would
export the whole class you could do whatever you want with it.
Can you provide a code example ?
I hope i have understood what your problem is.


cu

Peter




HPH
Using __declspec(dllimport) and __declspec(dllexport)
ahh.
I think maybe what your looking for is

#ifdef __cplusplus
extern "C" {
#endif

// function declarations

#ifdef __cplusplus
}
#endif



JS
http://www.thepeel.com/void
JShttp://www.thepeel.com/void
Advertisement


hmm... i don''t think i have explained this well. i am writeing a DLL. this requires that exported functions be declared as _cdecl this we know. however, for some reason ALL of my functions have ben made _cdecl not just the ones i declare as such. now, i am overloading some functions which handle linked lists of different types of data. since these functions take pointers, the size of the operands are the same. This generates an error outside of C++ decoration rules.

void * func(struct someLL_T **, int);
void * func(struct otherLL_T **, int);

now i don''t declare these with any specifiers.. and yet they are compiled with _cdecl type .... now, i don''t want any of the specifier types, i want normal C++ decorations back. my question is how to do this.




RanXact@yahoo.com
Well, I still don''t understand, but _cdecl is the standard and default. There is nothing wrong with it, and does not effect name decoration (although I believe that in order to export functions, they need to be declared as _stdcall, not _cdecl. But again, that doesn''t affect name mangling).

Rock


Well, I give up. so... i think i will just give all of the functions different names.. and not worry about overloading the functions.. even if it would look nicer.

Thanx anyway guys (and gals if any),
RanXacT
RanXact@yahoo.com

This topic is closed to new replies.

Advertisement