|
-
April 20th, 2009, 03:30 PM
#1
Stdcall naming convention & Excel
Hello,
It's been few hours since I started writing C++ DLL in order to use them in my Excel's worksheets, and I'm dealing with a naming problem.
When I make a C++ function, I write something like :
Code:
extern "C" __declspec (dllexport) int __stdcall
getOne() {
return 1;
}
The dll is compiled with VS 2008.
Then, in Excel (2007), I write :
Code:
Declare Function getOne Lib _
"..PATH..\dll_for_excel.dll" _
() As Long
Function getOneByC(trigger As Double) As Double
getOneByC = getOne()
End Function
And... it does not work. As a result, I get "#VALUE!", which means that Excel did not find a function named "getOne" in my DLL. So, I run dumpbin /exports and I see that my getOne function has been renamed as "_getOne@0".
After reading documentation on the Internet, I've come to the conclusion that such a name is a consequence of using __stdcall (@0 because no argument, etc..).
The only solution to overcome this problem I found is to use a DEF file. If so, all the "declspec(...)" and "extern "C" " are useless!
Of course, I can't use "_getOne@0" as a name in my Excel's declaration. And it would not be an acceptable solution.
Does anyone know how to proceed in order to avoid the DEF file and have it working ?
Thank you
C.L
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|