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
1
vote
1 answer

gcc cdecl calling convention

test a cdecl calling convention,but it's a little confusion about this: original C code: int __attribute__((cdecl)) add(int a,int b) { int i; i = a+b; return i; } void __attribute__((cdecl)) print(int i, ...) { int…
John
  • 11
  • 1
  • 2
1
vote
0 answers

Issues passing a C# callback pointer to a C library

I have built a C# library that accesses a C dll. The C dll accesses an API that taps a communication bus. When a message is received on that bus, it generates an interrupt that runs a function (defined as a __cdecl pointer to a function in the C#…
BampyRocket
  • 96
  • 1
  • 11
1
vote
0 answers

'cdecl attribute ignored error' and how to solve this error?

i'm using gcc on ubuntu 20.04 ,gcc version 9.4.0 i use opensources which is 'xsens-old' and then i typed cmake.. and then i got below error result how to solve this problem?? what does that mean 'attribute ignore' in this situations? 'error…
joe
  • 11
  • 1
1
vote
1 answer

Warning (C28251) when replacing "operator new": Inconsistent annotation for 'new', this instance has no annotations

I'm trying to replace the global new operator in Visual Studio and C++. This is my code (only one new operator shown for simplicity): void* operator new(size_t _Size) { // Do something } It works fine, however Visual Studio is giving me a…
Marc
  • 338
  • 2
  • 15
1
vote
1 answer

C# / C++ passing struct got Access Violation Exception

Good morning, I'm tring to implement a pos device. The native api is a C++ lib, that I have to use in my C# project. I already imported almost all the functions required (working fine), but there is one of them that I cannot do it anyway. This is…
1
vote
1 answer

Calling convention to use for max. portability between x86 systems

I am working on a set of self-contained x86 assembly routines that I would like to make available to C programs on systems below: Linux 64-bit only Windows 32-bit and 64-bit (Good to have ultimately, Mac 64-bit, but this is not clear as Apple…
user14222280
1
vote
1 answer

How can ctypes infer the types of integers that are passed?

I am interfacing this C code: extern "C" void print_int(short a, int b, long c, long long d) { printf("%hi %i %li %lli", a, b, c, d); } with this Python code: from ctypes import * lib=cdll.LoadLibrary("./libtest.so") lib.print_int(1,2,3,4) Even…
wecx
  • 302
  • 2
  • 10
1
vote
0 answers

Why is a struct of two doubles passed via registers but a struct of three doubles passed on the stack?

The following code: struct Double2 { double a; double b; }; struct Double3 { double a; double b; double c; }; double double2(struct Double2 x) { return x.a + x.b; } double double3(struct Double3 x) { return x.a + x.b +…
Jesse
  • 6,725
  • 5
  • 40
  • 45
1
vote
1 answer

A heap has been corrupted: When calling unmanaged function

I am calling an un-managed and very simple C++ function (located in JNIDiskInfoDll.dll) from a C# managed one as follows: C++: #include "stdafx.h" #include "AtaSmart.h" #include #include extern "C" __declspec(dllexport) char*…
peter bence
  • 782
  • 3
  • 14
  • 34
1
vote
1 answer

stdcall and cdecl stack alignment size

I have two questions: Is the stack alignment for the stdcall calling convention always 4 bytes, or is it 4 for a 32 bit machine and 8 for a 64 bit machine? What is the stack alignment size for cdecl? I am using Microsoft Visual Studio 2010.
Jin
  • 11
  • 2
1
vote
0 answers

passing character pointers to an external x86 32bit function

I am trying to write a small program that takes two hard coded character pointers and switches the contents that they point to using an external x86 32bit function located in a .S file. I am using the basic gcc compiler. Here is my C…
Sam K9
  • 99
  • 9
1
vote
1 answer

Pascal and cdecl keyword in C language

An interview question arise a strong confusion in my mind i.e Lets see this program #include "stdio.h" int main() { static int a=25; void cdecl conv1(); void pascal conv2(); conv1(a); conv2(a); return 0; } void cdecl…
Bhavya
  • 53
  • 1
  • 8
1
vote
2 answers

Swapping two int pointers in assembly x86

I want to swap two int pointers. I can do it in C like this void swap(int* a, int* b) int temp = *a; *a = *b; *b=temp; Now I'm trying to do it in assembly but, and bear with me, I don't understand why this doesn't work push %ebp mov…
codetective
  • 86
  • 2
  • 9
1
vote
1 answer

Use C lib (dll) in java with specific c call convention cdecl

I am working on a project where I have some sensors and I want them to connect to a PC via USB. now they write there is a windows lib written in c and all functions are using the cdecl call convention of c and I have to be sure that if I programm in…
white91wolf
  • 400
  • 4
  • 18
1
vote
1 answer

How to get pointer to outcoming buffer using asm?

I have to write function in asm, and i have prototype in C void fdct(float *in, float *out, unsigned int n); Where: in: pointer to incoming data buffer out: pointer to outcoming data buffer n: amount of data matrices. Function doesn't return…
Arina Boiko
  • 143
  • 1
  • 9