Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
218 Views

How to set the calling convention for a function pointer?

How to set the calling convention for a function pointer in ICL?
i tried:
typedef void __stdcall (*LPFNCALLBACK)(int);
this works with other compilers, but the intel compiler sais "a calling convention may not be followed by a nested declarator".
0 Kudos
7 Replies
Highlighted
Employee
218 Views

The above syntax gets a syntax error with the Microsoft compiler also.

Try:

typedef void (__stdcall *LPFNCALLBACK)(int);
0 Kudos
Highlighted
Valued Contributor II
218 Views

...works with other compilers...

I partially confirmthe statement. Here are someresults for a declaration:

typedef void __stdcall (*LPFNCALLBACK)(int);

I tried to compile with4 non Intelcompilers:

MS Visual Studio 2005 // Error C2059: syntax error : '('
Borland C++ v5.1.1 // Compiled
MinGW v3.4.2 // Compiled
Turbo C++v3.0.0 // Error: ) expected

So, it is 50-50 in my tests.

Best regards,
Sergey
0 Kudos
Highlighted
Valued Contributor II
218 Views

An Additional Review:

Final results for a declaration:typedef void __stdcall (*LPFNCALLBACK)(int);

Intel C++ // Some error
MS Visual Studio 2005 // Error C2059: syntax error : '('
Borland C++ v5.1.1 // Compiled
MinGW v3.4.2 // Compiled
Turbo C++v3.0.0 // Compiled ( __stdcall is not supported and _cdecl was used instead )

So, it is 40-60now.

Best regards,
Sergey
0 Kudos
Highlighted
Employee
218 Views

Om Windows Intel compiler is compatible with Microsoft compiler and on Linux Intel compiler is compatible with gcc.

0 Kudos
Highlighted
Valued Contributor II
218 Views

...On Windows Intel compiler is compatible with Microsoft compiler and on Linux Intel compiler is compatible with gcc...

Let me "translate" your explanation to another form: If a software developer implemented some code in C/C++ with Intel compiler it would be impossible to port the codewithout modifications to Linux. Right?

Look, there are standards and specifications forC and C++ languages.

For example, Turbo C++ v3.x.x,more than 20 year old compiler for MS DOS operating system!,supports C++ standard 2.1 and version 3.0 templates.

I wonder if that error, in case ofIntel and Microsoft,is some kind littledeviation from these standards.

Also, such declaration is Not a feature ofC++. It is a way howa software developercoulddeclare a typedef in C language. Pesonally, I always use thesecond form of the declaration.

Best regads,
Sergey

0 Kudos
Highlighted
Employee
218 Views


> Let me "translate" your explanation to another form: If a software developer implemented some code in
> C/C++ with Intel compiler it would be impossible to port the codewithout modifications to Linux. Right?

That is probablycorrect for any non trivial program (A "hello world" program would I'msure workcorrectly on both platforms).We guarantee both source and link compatibility with the Microsoft compiler on Windows and have put in hundreds,perhaps thousands,of fixes for this. Same thing on Linux, we have spent many years and put in hundreds and hundreds of changes in order to guarantee GNU compatibility. Is it not just a "little" deviation. We also have hundreds of differences based upon Gnu compiler version and Microsoft compiler version.On Linux you can useour -strict_ansi option for closer adherence to the standard and on Windows you can use the /Za option.

If we only implemented standard C++ then we would need our own set of system headers and libraries and users could not mix and match with binaries/libraries created by the reference compiler.

I don't know what "C++ standard 2.1 and version 3.0 templates" means. The C andC++ standards areusually referred to by the yearthey were published, i.e. C++ 1998 or C++ 2011 or C 1999. Are you referring to compatiblity with the original AT&T cfront compiler or the edition of the Stroustrup book?

Calling conventions are not part of the C or C++ standards (because they are platform specific)so there is no "standard" syntax for them.
0 Kudos
Highlighted
Valued Contributor II
218 Views

>>...The C andC++ standards areusually referred to by the yearthey were published, i.e. C++ 1998
>>or C++ 2011 or C 1999. Are you referring to compatiblity with the original AT&T cfront compiler or
>>the edition of the Stroustrup book?..

Partially Yes. For example, for Turbo C++ v3.xthis is before1992 or so, for Borland C++ v5.xthis is before1993, or so.
0 Kudos