Questions tagged [cdecl]

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

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

See Wikipedia on:

101 questions
3
votes
2 answers

Is it possible to have an exported function in __stdcall and the name unmangled?

I am working on a project to generate a dummy DLL for offline testing. We have the real DLL and its header file, though they seem incompatible. The names in the DLL are unmangled but the function forward declarations declarations are called out as…
J Collins
  • 2,106
  • 1
  • 23
  • 30
3
votes
1 answer

Library for parsing C Type Declarations?

I am trying to find an open source library (either written in C or C++) to help me parse arbitrary C/C++ type declarations (e.g declarations like void *(*(*foo[])( int, void * [] ))[123]) which I am then going to meta model. Can anybody recommend an…
Bobby
  • 43
  • 5
2
votes
1 answer

The value of ESP was not properly saved.... and C/C++ calling conventions

I am writing an application using the OpenCV libraries, the Boost libraries and a pieve of code that I have downloaded from this LINK. I have created a project under the same solution with Thunk32 and I have the following…
2
votes
1 answer

Calling convention for variadic function

When you initialize a variadic list, you use the macro va_start and pass list_name followed by the last fixed parameter before the va list starts because "the last fixed parameter neighbors the first variable one" and somehow this helps identifying…
Cătălina Sîrbu
  • 1,253
  • 9
  • 30
2
votes
2 answers

Confusion with function pointer, __cdecl, and template

In Visual Studio 2019, I have written the following test codes, but the results confused me. #include using namespace std; template int call(T x, Func f) { return f(x); } int square(int x) { return x * x; } int…
WhatsUp
  • 1,618
  • 11
  • 21
2
votes
2 answers

Problems with _cdecl using indirect recursion

I've written a factorial computation program that works up until the final computations. When it is calculating the factorial value in _multiply_fact, the base pointer ends up pointing to a random value. What am I doing wrong? Calling push n call…
Ieaturaw
  • 123
  • 1
  • 1
  • 5
2
votes
2 answers

Is it necessary to save the FPU state here?

I wrote a simple cooperative multi-threading library. Currently I always save and restore the fpu state with fxsave / fxrstor when switching to a new context. But is this necessary in the cdecl calling convention? As a simple example: float…
user5434231
  • 579
  • 3
  • 16
2
votes
2 answers

Mixed calling conventions make compilation errors

I have a library (C++) which has some API functions. One of them is declared as __cdecl, but gets a function poiner from __stdcall. Something like: typedef int (__stdcall *Func)(unsigned char* buffer); //... int ApiFunc(Func funcPtr); //This is…
Allen L
  • 127
  • 1
  • 11
2
votes
1 answer

c++ how does object-value return from function in details

Embedded types like int, char etc could be returned from function using registers, but what if function return some large object. I suggest process's stack couldn't be used for such issue, am I right? Could anyone explain how does object passed to…
vard
  • 2,142
  • 4
  • 30
  • 40
2
votes
2 answers

CDECL Calling Convention Causing strange warnings ASSEMBLY X86

Hi people I am new keen learner to assembly language x86, i am trying to produce a CDECL Call Convention from a set of encryption instructions. I believe I am going somewhere wrong down the line implementing the convention. Below is the original set…
DamonJnr
  • 35
  • 1
  • 3
2
votes
1 answer

how are signed char and short passed as parameter in cdecl call convention

For example int foo(short x); short s = -1; foo(s); Is it same as //int foo(short x); //Updated int foo(signed x); short s = -1; foo((signed)s);//sign-extend and push to stack Or is it same as //int foo(short x); //Updated int…
HarryLeong
  • 303
  • 1
  • 8
2
votes
1 answer

assigning functions to std::function with same signature, but different calling convention fails

the following compiles and runs just fine with mingw 4.7.2 and -m64 flag. but with -m32 or with any mingw 32bit release it fails to compile. is it a bug or am i missing a compiler flag? #include #include using…
user1283078
  • 2,006
  • 17
  • 17
2
votes
1 answer

Can't link to lib after VS2010 upgrade (__cdecl vs __thiscall?)

Any help much appreciated, my forehead's getting bruised. We have a big open source DICOM library (dcmtk) we use as a static lib. It's unmanaged C++, and we're linking to it from a managed C++ DLL that wraps it. It uses CMake to munge up the build…
Riker
  • 85
  • 6
2
votes
1 answer

What does the Apple documentation mean when it refers to the correct place to include ARC attributes?

When casting around (no pun intended) to clarify when to use __strong in a variable declaration I came across these lines in the Transitioning to ARC Release Notes: You should decorate variables correctly. When using qualifiers in an object…
Swizzlr
  • 447
  • 4
  • 15
1
vote
1 answer

How to force cdecl on variadic function

I'm writing a 64bit operating system using g++, and I have a variadic function like: void DbgPrint(const char *fmt, ...); which shall behave quite like printf. The problem here is that g++ follows the System V ABI, and thus it passes the first…
Francesco Boffa
  • 1,402
  • 1
  • 19
  • 35