From c4d99e3ea14eaabade8c3252a8df936ce33ca2e7 Mon Sep 17 00:00:00 2001 From: Roland Kaufmann Date: Wed, 27 Jun 2012 15:04:41 +0200 Subject: [PATCH] Specify namespace of math functions to avoid name clashes In the 4.6.x range of GNU compilers, the cmath header include math.h, adding isinf() and isnan() to the global namespace as well as std. When used in if statements, there is then an ambiguity between the std version which returns bool and the global function which returns int; for more details see: If we qualify the functions explicitly with their namespace, this error goes away. --- examples/upscale_cap.cpp | 2 +- examples/upscale_cond.cpp | 2 +- examples/upscale_relperm.cpp | 2 +- examples/upscale_relpermvisc.cpp | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/upscale_cap.cpp b/examples/upscale_cap.cpp index bc41986..ce18960 100644 --- a/examples/upscale_cap.cpp +++ b/examples/upscale_cap.cpp @@ -553,7 +553,7 @@ int main(int varnum, char** vararg) } // Check for saneness of Ptestvalue: - if (isnan(Ptestvalue) | isinf(Ptestvalue)) { + if (std::isnan(Ptestvalue) || std::isinf(Ptestvalue)) { cerr << "ERROR: Ptestvalue was inf or nan" << endl; break; // Jump out of while-loop, just print out the results // up to now and exit the program diff --git a/examples/upscale_cond.cpp b/examples/upscale_cond.cpp index 8ffe921..6bdbfee 100644 --- a/examples/upscale_cond.cpp +++ b/examples/upscale_cond.cpp @@ -713,7 +713,7 @@ int main(int varnum, char** vararg) } // Check for saneness of Ptestvalue: - if (isnan(Ptestvalue) | isinf(Ptestvalue)) { + if (std::isnan(Ptestvalue) || std::isinf(Ptestvalue)) { if (isMaster) cerr << "ERROR: Ptestvalue was inf or nan" << endl; break; // Jump out of while-loop, just print out the results // up to now and exit the program diff --git a/examples/upscale_relperm.cpp b/examples/upscale_relperm.cpp index 7cf2e29..db4f73c 100644 --- a/examples/upscale_relperm.cpp +++ b/examples/upscale_relperm.cpp @@ -1187,7 +1187,7 @@ int main(int varnum, char** vararg) } // Check for saneness of Ptestvalue: - if (isnan(Ptestvalue) | isinf(Ptestvalue)) { + if (std::isnan(Ptestvalue) || std::isinf(Ptestvalue)) { if (isMaster) cerr << "ERROR: Ptestvalue was inf or nan" << endl; break; // Jump out of while-loop, just print out the results // up to now and exit the program diff --git a/examples/upscale_relpermvisc.cpp b/examples/upscale_relpermvisc.cpp index 4d1c6f8..4d974cb 100644 --- a/examples/upscale_relpermvisc.cpp +++ b/examples/upscale_relpermvisc.cpp @@ -1081,7 +1081,7 @@ int main(int varnum, char** vararg) } // Check for saneness of fracFlowRatioTestvalue - if (isnan(fracFlowRatioTestvalue) || isinf(fracFlowRatioTestvalue)) { + if (std::isnan(fracFlowRatioTestvalue) || std::isinf(fracFlowRatioTestvalue)) { if (isMaster) cerr << "ERROR: fracFlowRatioTestvalue was inf or nan." << endl; break; // Jump out out while-loop, just print the results up to now and exit }