- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have the following constructs in place for language inter-operability
void CALLMETH hello_world()
{
}
So that on the command line I can say
-DCALLMETH=stdcall
And this works fine but how do I null out CALLMETH?
I have tried
-DCALLMETH=" "
and while this seems to work on a typed in command, tossing it into a Cygwin shell script it gets really messy.
Can I use some incantation using # or ## here ? All I really want to do is turn CALLMETH in whitespace.
By the way just using -DCALLMETH replaces CALLMETH with the number 1 ( as it should ).
Regards
Carl
void CALLMETH hello_world()
{
}
So that on the command line I can say
-DCALLMETH=stdcall
And this works fine but how do I null out CALLMETH?
I have tried
-DCALLMETH=" "
and while this seems to work on a typed in command, tossing it into a Cygwin shell script it gets really messy.
Can I use some incantation using # or ## here ? All I really want to do is turn CALLMETH in whitespace.
By the way just using -DCALLMETH replaces CALLMETH with the number 1 ( as it should ).
Regards
Carl
Link Copied
5 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I don't quite follow the context, i.e. when you want to undefine the symbol?
There's /undefine (/U) compiler switch which does the undefinition, but it's not clear to me what's its scope.
There's /undefine (/U) compiler switch which does the undefinition, but it's not clear to me what's its scope.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Carl,
This is a C problem question on a Fortran forum. That said consider inserting into a common header
#ifndef CALLMETH
#define CALLMETH
#endif
Then in your IDE settings (or command line) either a) define CALLMETH (as stdcall etc...) or b) not define CALLMETH.
When not defined, the above sets CALLMETH to empty space.
Jim Dempsey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Actually it is posted here because Intel FORTRAN now supports FPP (a cpp clone) so pre -processor usage is applicable to both FORTRAN and C,and this revolves around c and fortran interoperability. (sorry if I sound testy ... had my head inside compilers for to long)
Coming out of the CVF world we used the paradigm for C functions as
int CALLMETH c_to_be_called_by_f()
{
}
and we would do a -DCALLMETH=STDCALL
and after running the preprocessor the line would become:
int STDCALL c_to_be_called_by_f()
which was fine for CVF, but now under IF9.1 (since Intel is adopting the MS calling conventions by default)
the line needs to become
int c_to_be_called_by_f()
effectively nulling out the preprocessor macro.
Now the previous suggestion of -U (undefine the fpp macro) doesn't work because the code the compiler sees is really .....
int CALLMETHc_to_be_called_by_f()
and this makes no sense at all to a compiler.
I have tried a "hack" of
-DCALLMET=/**/
which results in a line that should look like ...
int /**/ c_to_be_called_by_f()
which most C compilers should take, but kinda looks ugly, and what is the equivalent in FORTRAN?
Coming out of the CVF world we used the paradigm for C functions as
int CALLMETH c_to_be_called_by_f()
{
}
and we would do a -DCALLMETH=STDCALL
and after running the preprocessor the line would become:
int STDCALL c_to_be_called_by_f()
which was fine for CVF, but now under IF9.1 (since Intel is adopting the MS calling conventions by default)
the line needs to become
int c_to_be_called_by_f()
effectively nulling out the preprocessor macro.
Now the previous suggestion of -U (undefine the fpp macro) doesn't work because the code the compiler sees is really .....
int CALLMETHc_to_be_called_by_f()
and this makes no sense at all to a compiler.
I have tried a "hack" of
-DCALLMET=/**/
which results in a line that should look like ...
int /**/ c_to_be_called_by_f()
which most C compilers should take, but kinda looks ugly, and what is the equivalent in FORTRAN?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Keep the =, but don't put anything after it other than one or more spaces (or have it at the very end of the command line).
If you were applying this to a fortran program:
ifort /fpp /DCALLMETH= ...rest of the command line...
Are you aware of the C interoperability feature introduced with the Fortran 2003 standard? Life in between the C and Fortran worlds is much simpler if you take advantage of this.
IanH
If you were applying this to a fortran program:
ifort /fpp /DCALLMETH= ...rest of the command line...
Are you aware of the C interoperability feature introduced with the Fortran 2003 standard? Life in between the C and Fortran worlds is much simpler if you take advantage of this.
IanH
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting - carlls
and after running the preprocessor the line would become:
int STDCALL c_to_be_called_by_f()
which was fine for CVF, but now under IF9.1 (since Intel is adopting the MS calling conventions by default)
the line needs to become
int c_to_be_called_by_f()
int STDCALL c_to_be_called_by_f()
which was fine for CVF, but now under IF9.1 (since Intel is adopting the MS calling conventions by default)
the line needs to become
int c_to_be_called_by_f()
For that particular case, you can define it to be "_cdecl" for IVF (and for CVF, better use "_stdcall" than "STDCALL" -- the first one is built-in in the MSVC compiler and the other comes from windows.h).
For a general case, I don't know. Maybe -DCALLMET="" will work, but it's a wild guess.

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