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

Progress ABL How to Test for WEBSPEED in the PRE-PROCESSOR
I want to nest include files inside include files. Why cant I do that in Inno Setup?
Discriminating between (small) numbers and everything else in C preprocessor
Defining preprocessor symbols for CLion analyzer
Check multiple conditions at once using m4 preprocessor
XC8 warning: (107) illegal # directive “foo”
Compiling with ocamlbuild and camlp5
How not to output comments using the -C operation in mcpp
C++ Builder File Version not correct
How do you a preprocess statement for #include
Does the preprocessor pass environment variables?
YAML preprocessor / macro processor
Pre-Processing using m4
Is there a practical reason for “#if defined(X) && (X != 0)”?
How to check for presence of a directory in Inno Setup preprocessor?
What are analogs of “#ifdef”, “#ifndef”, “#else”, “#elif”, “#define”, “#undef” in D programming lnaguage?

Categories

HOME
kentico
3d
r-googlesheets
pdfbox
permissions
tail
python-multithreading
little-proxy
ibeacon-android
nancy
libusb
standards
chargify
pyramid
nim
squashfs
tosca
gmock
custom-post-type
stackexchange
jasmine-node
soot
sqlpackage
aws-codecommit
r-grid
swagger-php
google-data-api
preloader
android-exoplayer
signal-strength
jboss-4.2.x
stdmap
java-6
avx
pdf-conversion
janus
preprocessor
x-tag
http-status-code-401
riot
yajsw
inf
grgit
gocql
forwarding
flock
page.js
apache-commons-daemon
avahi
dnssec
nutiteq
typeconverter
cakephp-2.7
dot.js
actionfilterattribute
broadband
public-html
cross-join
showdialog
execve
post-commit-hook
iso-prolog
strawberry-perl
create.js
ios8-extension
radiant
android-framework
visual-studio-express
modular
cmmi
css-reset
bjyauthorize
booksleeve
web-notifications
subgraph
objectquery
fitbounds
urlrewriter
multiplatform
presentation-layer
ruby-1.8
pos-for-.net
sifr
duplex
silverlight-oob
visualj#
sun
cldc
httpcookie
mathematical-typesetting

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