Questions tagged [stdcall]

Anything related to the `stdcall` calling convention, i.e. one of the common subroutine calling conventions used on systems with x86 architecture.

Anything related to the stdcall calling convention, i.e. one of the common subroutine calling conventions used on systems with x86 architecture.

See Wikipedia on:

150 questions
176
votes
8 answers

What is __stdcall?

I'm learning about Win32 programming, and the WinMain prototype looks like: int WINAPI WinMain ( HINSTANCE instance, HINSTANCE prev_instance, PSTR cmd_line, int cmd_show ) I was confused as to what this WINAPI identifier was for and found: #define…
Tristan Havelick
  • 67,400
  • 20
  • 54
  • 64
102
votes
9 answers

stdcall and cdecl

There are (among others) two types of calling conventions - stdcall and cdecl. I have few questions on them: When a cdecl function is called, how does a caller know if it should free up the stack ? At the call site, does the caller know if the…
Rakesh Agarwal
  • 3,009
  • 9
  • 33
  • 40
70
votes
2 answers

Why are Cdecl calls often mismatched in the "standard" P/Invoke Convention?

I am working on a rather large codebase in which C++ functionality is P/Invoked from C#. There are many calls in our codebase such as... C++: extern "C" int __stdcall InvokedFunction(int); With a corresponding C#: [DllImport("CPlusPlus.dll",…
Kadaj Nakamura
  • 923
  • 1
  • 10
  • 24
25
votes
3 answers

Is there STDCALL in Linux?

I'm trying to port a Windows app to Linux. This appplication marks some functions with the __stdcall attribute. However, I was told by a friend that stdcall is used only on Windows and has no meaning in Linux (but DOES exist in Windows…
Break Point
  • 309
  • 1
  • 3
  • 5
17
votes
2 answers

stdcall name mangling using extern c and dllexport vs module definitions (msvc++)

I was trying to export a simple test function for a dll to work with an application (fyi: mIRC) that specifies the calling convention as: int __stdcall test_func(HWND mWnd, HWND aWnd, char *data, char *parms, BOOL show, BOOL nopause) Now, to call…
mina
  • 439
  • 2
  • 7
  • 13
16
votes
4 answers

declspec and stdcall vs declspec only

I'm a new person to C++ dll import topic and may be my question is very easy but I can not find it on google. I have a very simple C++ win32 dll: #include using namespace std; extern "C" { __declspec(dllexport) void __stdcall…
ilyaw77
  • 937
  • 3
  • 10
  • 15
12
votes
1 answer

Is there any equivalent for stdcall in GCC?

I'm working on my own kernel using GCC, and when calling C functions from asm code, I have to do add esp,xx myself. After some searching I found that stdcall is a Microsoft invention and can't use it in GCC. Is there any handy way to do this work?
babel92
  • 767
  • 1
  • 11
  • 21
11
votes
9 answers

Create a C# DLL That Can Be Imported in a Delphi App Using stdcall - Possible?

I have a program that I need to create a DLL for, hopefully in C#. The program is written in Delphi and I have an interface file to code to. The interface uses the stdcall calling convention. Is it possible to create a C# DLL that conforms to the…
Dave
  • 5,436
  • 11
  • 48
  • 74
10
votes
4 answers

Changing Calling Convention

I have a 3rd party C API that expects a __stdcall callback function. My code has an externally-provided __cdecl callback function. I cannot pass my function pointer to the C-API as they are considered different types. Bypassing the type system and…
Adi Shavit
  • 16,743
  • 5
  • 67
  • 137
8
votes
1 answer

VC++ prevent all symbol name decorations

I'm working on a DLL which will be used from another language (so no import libs and including the dll's headers) using the _stdcall calling convetion. The problem is that VC++ seems to always do some name decoration on its exported symbols. All the…
SyncViews
  • 125
  • 1
  • 5
8
votes
3 answers

Template partial specialization for __stdcall function pointer

typedef bool (*my_function_f)(int, double); typedef bool (__stdcall *my_function_f2)(int, double); // ^^^^^^^^^ template class TFunction; template class TFunction { typedef R…
pure cuteness
  • 1,635
  • 11
  • 26
8
votes
2 answers

Why did Microsoft choose stdcall as their API convention?

Is there a good reason? Are their internal functions (not exported) also stdcall convention?
Benjamin
  • 10,085
  • 19
  • 80
  • 130
7
votes
1 answer

How to automate generating an import library from undecorated stdcall DLL?

The general way to deal with creating LIB from DLL is described in How to make a .lib file when have a .dll file and a header file - still, to create an import library for DLL with undecorated stdcall functions (e.g. core WinAPI DLL's, kernel32.dll…
Ivan Ivanov
  • 115
  • 1
  • 4
7
votes
3 answers

how are structs passed as parameters in assembly

How are structs passed as parameters in assembly? Since structs have sizes large than normal are the individual fields passed sequentially? If so are they in reverse order like normal parameters? Are their any differences between cdecl and stdcall?
7
votes
5 answers

In C++, do variadic functions (those with ... at the end of the parameter list) necessarily follow the __cdecl calling convention?

I know that __stdcall functions can't have ellipses, but I want to be sure there are no platforms that support the stdarg.h functions for calling conventions other than __cdecl or __stdcall.
Ben
  • 585
  • 1
  • 4
  • 19
1
2 3
9 10