- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
In my code, depending on the operating system (OS), I run different stuffs.
Is there a way to do it automatically thru the if...else syntax?
e.g. if (OS=="win7") then
...
else if (OS=="linxu") then
...
end if
Thanks and Merry Christmas!
In my code, depending on the operating system (OS), I run different stuffs.
Is there a way to do it automatically thru the if...else syntax?
e.g. if (OS=="win7") then
...
else if (OS=="linxu") then
...
end if
Thanks and Merry Christmas!
1 Solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
My apologies. Use this form instead:
!DEC$ IF DEFINED(_WIN32)
... Windows
!DEC$ ELSEIF DEFINED(__linux)
... Linux
!DEC$ ELSE
... Oops
!DEC$ ENDIF
!DEC$ IF DEFINED(_WIN32)
... Windows
!DEC$ ELSEIF DEFINED(__linux)
... Linux
!DEC$ ELSE
... Oops
!DEC$ ENDIF
Link Copied
6 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Since you have to build the program separately, use conditional compilation and the predefined symbols. For example:
!DEC$ IF (_WIN32)
... Windows
!DEC$ ELSEIF (__linux)
... Windows
!DEC$ ELSE
... Mac?
!DEC$ END IF
If you want to detect different Windows versions, see the provided sample Win32\Platform.
!DEC$ IF (_WIN32)
... Windows
!DEC$ ELSEIF (__linux)
... Windows
!DEC$ ELSE
... Mac?
!DEC$ END IF
If you want to detect different Windows versions, see the provided sample Win32\Platform.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sorry, can you explain more clearly?
I tried to add into my fortran code using:
!DEC$ IF (__linux)
call hypre_deallocate
!DEC$ END IF
but I got the error msg:
remark #5170: Invalid conditional compilation expression component
!DEC$ IF (1)
------^
Thanks again.
I tried to add into my fortran code using:
!DEC$ IF (__linux)
call hypre_deallocate
!DEC$ END IF
but I got the error msg:
remark #5170: Invalid conditional compilation expression component
!DEC$ IF (1)
------^
Thanks again.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
My apologies. Use this form instead:
!DEC$ IF DEFINED(_WIN32)
... Windows
!DEC$ ELSEIF DEFINED(__linux)
... Linux
!DEC$ ELSE
... Oops
!DEC$ ENDIF
!DEC$ IF DEFINED(_WIN32)
... Windows
!DEC$ ELSEIF DEFINED(__linux)
... Linux
!DEC$ ELSE
... Oops
!DEC$ ENDIF
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Thanks for the clarifications. Now there's no error, but even if I use:
!DEC$ IF DEFINED(_WIN32)
in linux, the statement below still gets executed.
I thought that it should be not so if my OS is linux.
Thanks for the clarifications. Now there's no error, but even if I use:
!DEC$ IF DEFINED(_WIN32)
in linux, the statement below still gets executed.
I thought that it should be not so if my OS is linux.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
That is not the way it is supposed to work. Please show a small test program and then a log of your building it on Linux, then running it. You aren't trying to run a Windows program under an emulator such as Wine, are you?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Ops, made a careless mistake. It worked, thanks for the Christmas present ;-)
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