- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'm trying to specify a Windows 32 calling convention on a function whose name is a macro, similar to the following:
#define AddPrefix(x) (prefix##x)
#define function AddPrefix(function)
void __cdecl function( void );
int main( int argc, char **argv )
{
return 0;
}
But the compiler raises the following error:
Intel(R) C++ Compiler XE for applications running on IA-32, Version 13.0.0.089 Build 20120731
Copyright (C) 1985-2012 Intel Corporation. All rights reserved.
test.c
test.c(4): error: a calling convention may not be followed by a nested declarator
void __cdecl function( void );
^
compilation aborted for test.c (code 2)
Is there anyway to specify a calling convention on declarations like this? I need to include a header file with declarations as in my example above into a C file built with -Gz, which causes __stdcall to be the default. Of course the shared library that matches the header was built without -Gz, so its exports are __cdecl.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
the problem is the parenthesis around the function name, can you change the AddPrefix macro to:
#define AddPrefix(x) prefix##x
Judy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Ok, I can work with that.
Thanks
Darin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This is not a bug. On Windows we emulate the Microsoft compiler and they give an error too.
Judy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Calling conventions are not part of the C or C++ standard. They are a Microsoft extension and thus Microsoft implemented the "de facto" standard.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page