CompuServe Thread

#C++ &-Referencing

5 messages in this thread
#24300From: Chuck LeamonFeb 28, 1990 7:14 AM
John, Sorry to butt in here, and this is probably subject for a different thread, _but_ I am curious. I am using Zortech C++ 2.0 to compile the multitasking kernal and have run into a couple of problems (haven't look at it again since but intend to), most important is the MASM call to the object's method which was unresolved. I understand name mangling somewhat, but don't know what changed between 1.0? and 2.0. Using 'dumpobj' I can see that at least one major change took place, which is reversing the class and member names. (ie. 1.0? uses ClassName_MemberName, 2.0 uses MemberName_ClassName OR vice versa). Can member functions be declared with 'cdecl'? What if it's virtual and subsequently sub-classed? I have a need to link to a hardware interrupt routine and just can't seem to resolve this linkage issue. Can you (or anyone here) help clarify this? Thanks in advance. C h u c k
#24301From: Greg Comeau@Comeau CmptgFeb 28, 1990 8:47 AM
If you want to stop the name mangling you can use 'extern "C"' for C linkage as in 'extern "C" int foo(type bar etc);'… not sure if that's what you want here though… (BTW, externC is a 2.0ism since 2.0 now support type safe linkage which essentially means prototype enforcement *across* source files not just within individual source files).
#24308From: Chuck LeamonFeb 28, 1990 5:42 PM
Greg, I guess I wasn't clear…what I need is to call a C++ function (member) from the ASM interrupt handler. Maybe I could create a "C" function as a friend and call the member::function from the "C" function. Thanks C h u c k
#24310From: Greg Comeau@Comeau CmptgFeb 28, 1990 11:28 PM
Yes, front ending the member function via a call to a non-member C++ function (with the appropriate args) that's been 'extern "C"'d is the simplest (and most portable) way.
#24304From: John M. DlugoszFeb 28, 1990 3:26 PM
As I understand it, your problem is linking with the ASM stuff. WHen prototyping the asm functions, use the "C" qualifier. extern "C" assembly_function (int, int); for example. Just stick in the "C" on all the prototypes for the ASM calls. Alternativly, change the name of the ASM function to the name Zortech is trying to link with. A few other problems you will have: enum values are now local to a class. Hoist the enum type def out of the class for a quick fix. –John