CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   Passing compiler options to wmake? (https://www.cfd-online.com/Forums/openfoam-programming-development/151571-passing-compiler-options-wmake.html)

Linse April 13, 2015 08:16

Passing compiler options to wmake?
 
Dear all,

while I am sure that most warnings during compilation can be mitigated by perfect code, sometimes it might be advantageous during debugging to add some additional compiler options.
For example during compiling of some code, wmake suggests to use "-Wreorder" as a compiler option. Alas, just running "wmake -Wreorder" does fail, telling me "-Wreorder" was an unknown option.
Thus my question is:

How can I pass on g++-options to the compilation with wmake?

Thanks for your answers already in advance!

Cheers,
Bernhard

alexeym April 13, 2015 09:06

Dear Bernhard,

Quote:

For example during compiling of some code, wmake suggests to use "-Wreorder" as a compiler option. Alas, just running "wmake -Wreorder" does fail, telling me "-Wreorder" was an unknown option.
In fact it is not wmake who suggests, it is g++. So you can use Make/options file for compiler options. Add compile time options to EXE_INC, link time options to EXE_LIBS.

Linse April 13, 2015 18:36

Thanks a lot for your message. Unfortunately it did not work. Seems, the options in brackets behind the compiler-warnings either were wrong or did come from something different...

If for example there is
OpenFOAM/OpenFOAM-2.3.x_latest/src/finiteVolume/lnInclude/readTimeControls.H:38:8: warning: unused variable ‘maxDeltaT’ [-Wunused-variable]
I would assume "-Wunused-variable" says what compiler option would switch of this warning.

But it definitely took the included options into account, as it checked them for right spelling (--Wreorder brought up an error, as it did not accept the double - in front).
Further ideas?

Cheers,
Bernhard

alexeym April 14, 2015 02:14

Hi,

To avoid assumptions about compiler behavior one can look into manual:

Quote:

You can request many specific warnings with options beginning with ‘-W’, for example -Wimplicit to request warnings on implicit declarations. Each of these specific warning options also has a negative form beginning ‘-Wno-’ to turn off warnings; for example, -Wno-implicit.
(https://gcc.gnu.org/onlinedocs/gcc-4...arning-Options)

And example, if I have these options:

Code:

EXE_INC = \
    ...
    -I$(LIB_SRC)/transportModels/incompressible/singlePhaseTransportModel \
    -DFOAM_VERSION=${FOAM_VERSION} \
    -Wreorder \
    -Wno-undefined-bool-conversion

during compilation I will get

Code:

In file included from myFoam.C:75:
$HOME/OpenFOAM/OpenFOAM-2.3.1/src/finiteVolume/lnInclude/readTimeControls.H:38:8: warning: unused variable
      'maxDeltaT' [-Wunused-variable]
scalar maxDeltaT =
      ^
1 warning generated.

so if I add to options:

Code:

EXE_INC = \
    ...
    -I$(LIB_SRC)/transportModels/incompressible/singlePhaseTransportModel \
    -DFOAM_VERSION=${FOAM_VERSION} \
    -Wreorder \
    -Wno-unused-variable \
    -Wno-undefined-bool-conversion

compilation finishes without warnings.

Linse April 14, 2015 04:01

Gosh, I always thought I was capable of thinking and remembering the famous four letter-paradigm of programming - rtfm.
But it seems sometime a reminder - moreover such a helpful one - is quite in place! ;-)

Thanks a lot, by now I know my warnings and compiler messages were of a low-urgency magnitude!


All times are GMT -4. The time now is 00:17.