Re: system function to determine OS
- From: user1 <user@xxxxxxxxxxx>
- Date: Wed, 25 Mar 2009 15:35:15 -0400
John Appleyard wrote:
Since this information is known at compile time, I think the best solution is to define a parameter with the value in, and stick it in a module. Then just uncomment the right one at compile time.
"Clever" ways to do this at run-time are liable to come unstuck when Apple/MS/Linux change the rules without telling you.
INTEGER,PARAMETER :: MAC=1,WINDOWS=2,LINUX=3
INTEGER,PARAMETER :: OS=MAC
!! INTEGER,PARAMETER :: OS=WINDOWS
!! INTEGER,PARAMETER :: OS=LINUX
Interesting. If doing this in C, I would use preprocessor macros and compile my program with cc -DUSING_MAC, cc -DUSING_LINUX, or cc -DUSING_WINDOWS.
My program would contain blocks like
#ifdef USING_MAC
--- do mac stuff ...
#endif
#ifdef USING_LINUX
--- do linux stuff ...
#endif
#ifdef USING_WINDOWS
--- do windows stuff ...
#endif
Is there a Fortran analog to this ?
.
- Follow-Ups:
- Re: system function to determine OS
- From: Ron Shepard
- Re: system function to determine OS
- From: e p chandler
- Re: system function to determine OS
- References:
- system function to determine OS
- From: John
- Re: system function to determine OS
- From: John Appleyard
- system function to determine OS
- Prev by Date: Re: system function to determine OS
- Next by Date: Re: Unexpected 15 digits precision from "REAL"
- Previous by thread: Re: system function to determine OS
- Next by thread: Re: system function to determine OS
- Index(es):
Relevant Pages
|