-1

I am trying to understand a makefile in which a Fortran code is used with cpp for preprocessing in the following manner,

cpp -P -traditional -DMPI -DLINUX -DX86_64 -DGFORTRAN -D'HEADER="testfile.h"' -D'ROOT_DIR="/home/Desktop"'...-D'FILE_DIR="/home/Desktop/MYFILES"' -I/usr/local/include file.F

I understood the usage of include directory but I am unable to understand the purpose of -D options (named as CPPFLAGS) listed here. I see that if I remove any of the -D option, my output is modified (I get only start and end of my program and no text in between).

Edit: I have a list of ifdef options and my makefile uses different subdirectories with -D option. What is it looking in those directories, Files in which the option is defined?

Agni
  • 147
  • 5

1 Answers1

0

If I understand you correctly, you just want to figure out the meaning of -D. gcc -D defines a macro to be used by the preprocessor. the syntax is below:

$ gcc -Dname [options] [source files] [-o output file]
$ gcc -Dname=definition [options] [source files] [-o output file]

If you remove any -D, it means this macro isn't defined. So your output might be changed.

  • Thanks but how will I get to know about which macro has to be used ?? I have mentioned the include directory as per the location of include file in my Fortran code but I don't have any idea about macros and their selection in preprocessing. – Agni May 22 '18 at 08:18
  • 1
    @nshwal That is completely set by the code you are compiling. You have to study the manual or the code. We cannot tell you what the individual macros do in your code. – Vladimir F Героям слава May 22 '18 at 08:21
  • @VladimirF it's the part of a model code and apart from technical manual I only have the makefile which I am trying to understand. – Agni May 22 '18 at 08:50