DLL name decorations 
Author Message
 DLL name decorations

I build a DLL that exports a function

extern "C" int WINAPI Test();

EXPORTS
Test

Then I call it in another VC projects, link with the .lib
file that was generated for the DLL project. I got a link


The question is, how does all WIN32 API works?

Thanks

Jack



Wed, 05 Oct 2005 01:36:20 GMT  
 DLL name decorations

Quote:
>I build a DLL that exports a function

>extern "C" int WINAPI Test();

>EXPORTS
>Test

>Then I call it in another VC projects, link with the .lib
>file that was generated for the DLL project. I got a link


Jack,

What's the exact symbol that it thinks is unresolved?

From the look of things, are you sure that your code that calls that
DLL function has the function prototype with the extern 'C' ?

Dave
--
MVP VC++ FAQ: http://www.mvps.org/vcfaq



Wed, 05 Oct 2005 03:34:53 GMT  
 DLL name decorations

Quote:
> I build a DLL that exports a function
> extern "C" int WINAPI Test();


It looks like the function is declared in the header as "C",
but the actual implementation is still C++. Is this the case?
It is not enough to declare the function in the header as C.
When you implement it you should do the same.

Mihai



Wed, 05 Oct 2005 15:10:08 GMT  
 DLL name decorations
Where you call the function you also have to declare it as WINAPI because
WINAPI is defined as__stdcall which is a calling convention that some
functions use to pass the number of bytes in the arguments list (see
__stdcall in the online help)

Ted.


Quote:
> I build a DLL that exports a function

> extern "C" int WINAPI Test();

> EXPORTS
> Test

> Then I call it in another VC projects, link with the .lib
> file that was generated for the DLL project. I got a link


> The question is, how does all WIN32 API works?

> Thanks

> Jack



Wed, 05 Oct 2005 20:15:35 GMT  
 DLL name decorations
Quote:
> Where you call the function you also have to declare it as WINAPI because
> WINAPI is defined as__stdcall which is a calling convention that some
> functions use to pass the number of bytes in the arguments list (see
> __stdcall in the online help)

Big warning: keep the same declaration in all places, in the header and in
the c/cpp file where you are implementing it.
Don't declare it WINAPI when you use it if it was not declared WINAPI when
you implemented it.
It is garanteed you will get a crash otherwise.

Mihai



Thu, 06 Oct 2005 16:10:15 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. DLL - name decoration

2. C DLL without name decoration

3. VC++ 6.0 name decoration for literals

4. name decoration

5. stdcall & fntn name decoration

6. Name Decoration problem

7. Name decoration

8. VC++ 5/VC++ name decoration differences example needed

9. Function name decoration when using _stdcall????

10. name decoration

11. decoration macro confuses browser

12. MDI child decorations

 

 
Powered by phpBB® Forum Software