Hi,

I would like to declare function with calling convention.
But getting following errors on CentOS 4.7 with GCC 3.4.6

test.c:3: error: syntax error before "display"
test.c:3: warning: data definition has no type or storage class
test.c:12: error: conflicting types for 'display'
test.c:3: error: previous declaration of 'display' was here
test.c:12: error: conflicting types for 'display'
test.c:3: error: previous declaration of 'display' was here

// Code
#include <stdio.h>

void __cdecl display(int i);

int main()
{
	display(20);
	return 0;
}

void display(int i)
{
  printf("%0x", i);
}

What is __cdecl ?

(asking OP, not everyone)

__cdecl is calling convention. which is default calling convention for c & c++.

others are:
__cdecl
__stdcall
__fastcall
...

I want to mention calling convention in function declaration.

__cdecl is calling convention. which is default calling convention for c & c++.

others are:
__cdecl
__stdcall
__fastcall
...

I want to mention calling convention in function declaration.

Such things are not standard C or C++, they are language extensions. They may or may not have any meaning for a given compiler. Where they do have meaning, the compiler should document their use.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.