Original Post
hello everyone I'm trying to learn about calling conventions.But I have some misunderstandings. I'm using two projects both build with Visual Studio 2005. The first project is c++ console app and the second is simple c++ dll.The .exe simply calls a function from the dll. The question is this : When I compile the .exe with default project settings to use __cdecl and the .dll default project settings to use __stdcall I get the following error "unresolved external symbol "int __cdecl sum(int,int)" (?sum@@YAHHH@Z) referenced in function _main" which is expected since there is mismatch in calling conventions. But ... when I explicitly specify in the function declaration in the dll the calling convention like this __declspec(dllexport) int _stdcall sum(int a,int b) I don't get the linker error although the default project settings for the .exe is still __cdecl and everything works fine.(no linker error and no stack corruption at runtime, and I checked assembly code also everything works ok. main function somehow knows to call sum using __stdcall). Why is this happening?I was expecting to get linker error since the default project settings for the .exe are to use __cdecl and the sum function is declared as __stdcall witch is mismatch.Isn't this basically the same like above explained when I got the linker error ? Why I don't got error this time? Thanks