I want to use two 3rd party libraries in my project but one was compiled with __stdcall convention and another with __cdecl. No matter what I set my project property to, the LINKER fails to link one library or another. Is there a way to do this?
Asked
Active
Viewed 853 times
2

Bo Persson
- 90,663
- 31
- 146
- 203

Anorflame
- 376
- 3
- 12
-
1Dude, 8 questions, 0% accepts? – Puppy Jul 21 '12 at 09:24
-
2Edit the .h file of the first one and insert __stdcall in the function declarations. – Hans Passant Jul 21 '12 at 09:35
-
@HansPassant That works. Thank you so much! Why don't you make your answer a proper answer so we can upvote it? – Mark Oct 03 '13 at 11:50
1 Answers
2
The calling convention external code is compiled with should be irrelevant. As long as the appropriate functions are declared with the correct convention, the convention you use for your own code matters not and it will work whatever choice you make.

Puppy
- 144,682
- 38
- 256
- 465
-
I agree, but I saw that if I just try to compile it without changing the declarations in one of the headers, the linker fails (described in more details in other question of mine). If the convention is not specified explicitly in the header, what convention is used for the imported functions? My assumption (correct me if I'm wrong) is that the one specified in the properties of the project or a specific file. In this case (I use one convention for the whole project while the 3rd party library was compiled with another), I think it makes sense that the linker failed. – Anorflame Jul 25 '12 at 19:55