0

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);
}

Edited by WaltP: Added CODE tags -- with all the help about them, how could you miss using them????

3
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by Dave Sinkula
0

__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.

0

__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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.