preprocessor


Gfortran pre-processor directives for Different Operating systems


Could you tell me please how can I do the following:
#if __unix__
#define path_sep='/'
#elif __windows__
#define path_sep='\'
#else
#error "path_sep not defined."
#endif
using gfortran compiler.
This can be done in combination with conditional compilation and using the "D" option on the command line. Here is some example code:
program test_Dopt
character (len=1) :: pathsep
pathsep = "?"
#ifdef WOS
pathsep = "\"
#endif
#ifdef UOS
pathsep = "/"
#endif
write (*, '( "pathsep is >", A1, "<")' ) pathsep
end program test_Dopt
Name the program with filetype F90 to cause gfortran to run the preprocessor or use -cpp on the compile line. Then pass options to the prepreprocessor by including them after D on the compile line, e.g., gfortran -DWOS. (This is more general then gfortran -- most Fortran compilers will process C-style pre-processor directives.) Then you can identify the OS outside of Fortran and pass the information to the Fortran program.
You can compile your code via using the filetype F90 or -cpp.

Related Links

complex preprocessor symbol for ede project
GNU-C-preprocessing FORTRAN source to change array indices causes recursion whilst expanding macro
indirectly quoting macro in traditional mode
KMP Preprocessing Function
How to detect Apportable with preprocessor flags?
Adjust data vector to have certain variance
Pre-process Laravel 4 view
File iteration with the preprocessor
processing strings of text for neural network input
How to Set Active Target in XCode 4.5+
Preprocessor assertions in arduino
expanding a macro within a macro definition
GNU-M4: Strip empty lines
Escaping space in OpenCL compiler arguments
Does Corona have preprocessor statements so I can execute Lua code for specific devices?
Preprocessing in C++

Categories

HOME
paraview
gdb
jmeter
mysql-workbench
camera
alsa
jquery-ui
webix
pkcs#11
qpython
fosrestbundle
pega
project-intu
why3
emoji
android-intent
do-while
coin3d
esoteric-languages
feathersjs
foreign-keys
apache2.4
asp.net-core-webapi
object-storage
windows-server-2003
itunes
pylons
mat
entity-relationship-model
rpgle
paperjs
realm-mobile-platform
hibernate-validator
catch-unit-test
laravel-eloquent
code-snippets
dsx-desktop
hreflang
android-gridview
installscript
salesforce-communities
sql-server-ce
reactivekit
xdocreport
verifiable-c
loading
spring-mvc-test
resolution
plaintext
print-css
configurationmanager
mongotemplate
openblas
tinkerpop
context-sensitive-grammar
modelsim
otp
cvxpy
gets
omxplayer
centrifuge
lrs
model-associations
eigenvector
udpclient
pre-build-event
data-protection
aurora
cda
httpruntime.cache
mobiledoc-kit
opl
r-package
rate-limiting
coda
aspectj-maven-plugin
bufferedinputstream
osc
zxspectrum
umlgraph
dbaccess
big-ip
nsmenu
verold
authlogic
decoupling
mt4j
notorm
embedded-fonts
oocss
workitem
android-icons
chart-director
robotlegs
xcode3.2
inkcanvas
u2netdk
automationelement
tmx
nhprof
load-time
cruisecontrol.rb
facebook-iframe
xpsdocument
product-management

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App