[Users] isnan & compile error: "'(' before 'Cactus'"?
Erik Schnetter
schnetter at cct.lsu.edu
Thu Jun 13 21:29:34 CDT 2013
Scott
(Sorry for being busy earlier.)
I am not aware of a system where isnan is not defined; hence putting things
into #ifdef won't help you -- you do have isnan.
Your problem is likely a syntax error because you forgot to enclose the if
condition into parentheses: if (isnan(6.0)) {}
In C++, there are compilers that closely follow the C++ standard, and there
are older compilers that don't, and which instead follow the C standard.
That makes it difficult to use isnan, and Cactus thus works around this to
provide isnan as specified in the C++ standard. It does so by first
"capturing" isnan in whichever way it is provided by the compiler, then
providing a function Cactus::good_isnan that is known to work, and then
defining a macro isnan that expands to "Cactus::good_isnan". This mechanism
explains your error regarding "Cactus".
-erik
On Thu, Jun 13, 2013 at 6:41 PM, Scott Hawley <scott.hawley at belmont.edu>wrote:
> Hi, I'm confused as to why using "isnan" should produce an error involving
> "Cactus". I've pulled code out and reduced it to a mere isnan call, and
> even placed it within HAVE_ISNAN....
>
> #ifdef HAVE_ISNAN
> if isnan(1.0) {}
> #endif
>
> (Ultimately I want isnan(gxx[CCTK_GFINDEX3D(cctkGH, i,j,k)]) in there...)
>
>
> Here's the error:
>
> %make bruiser SILENT=no
> ..
> COMPILING
> /Users/shawley/Cactus/arrangements/Bruiser/BruiserConstraints/src/BruiserUt
> il.cc
> current_wd=`pwd` ; cd /Users/shawley/Cactus/configs/bruiser/scratch ;
> /opt/local/bin/g++-mp-4.7 -m64 -fopenmp -g -O0 -O2 -c -o
> $current_wd/BruiserUtil.cc.o $current_wd/BruiserUtil.cc
> -I"/opt/local/include/openmpi" -I"/opt/local/include/openmpi"
> -I"/opt/local/include/openmpi" -I"/opt/local/include/openmpi"
> -I"/Users/shawley/Cactus/arrangements/Bruiser/BruiserConstraints/src"
> -I"/Users/shawley/Cactus/arrangements/Bruiser/BruiserConstraints/src/includ
> e" -I"/Users/shawley/Cactus/configs/bruiser/config-data"
> -I"/Users/shawley/Cactus/configs/bruiser/bindings/include"
> -I"/Users/shawley/Cactus/src/include"
> -I"/Users/shawley/Cactus/arrangements"
> -I"/Users/shawley/Cactus/configs/bruiser/bindings/Configuration/Thorns"
> -I"/Users/shawley/Cactus/configs/bruiser/bindings/include/BruiserConstraint
> s" -I"/opt/local/include/openmpi" -I"/opt/local/include/openmpi"
> -I"/opt/local/include/openmpi" -I"/opt/local/include/openmpi"
> -I"/Users/shawley/Cactus/arrangements/Bruiser/BruiserConstraints/src"
> -I"/Users/shawley/Cactus/arrangements/Bruiser/BruiserConstraints/src/includ
> e"
> -I"/Users/shawley/Cactus/configs/bruiser/bindings/include/BruiserConstraint
> s" -DCCODE
> /Users/shawley/Cactus/configs/bruiser/build/BruiserConstraints/BruiserUtil.
> cc: In function 'void BruiserF2CIBFillVar(cGH*, int, int, int, int,
> maskcodes_type)':
> /Users/shawley/Cactus/configs/bruiser/build/BruiserConstraints/BruiserUtil.
> cc:461:30: error: expected '(' before 'Cactus'
> make[3]: *** [BruiserUtil.cc.o] Error 1
> make[2]: *** [make.checked] Error 2
>
>
>
> Pulling the raw code itself shows no lines with "Cactus" in them, so
> apparently "isnan" has NOT been redefined by some header:
> % sed -n 460,462p
> /Users/shawley/Cactus/configs/bruiser/build/BruiserConstraints/BruiserUtil.
> cc
> #ifdef HAVE_ISNAN
> if isnan(6.0) {}
> #endif
> %
>
>
> I'm guessing this is one of those cases where the error being reported is
> not the "real" error. So I checked to make sure parentheses and curly
> braces are opened & closed appropriately.
>
> Any suggestions for how to fix this?
> Thanks.
>
>
>
>
>
>
> _______________________________________________
> Users mailing list
> Users at einsteintoolkit.org
> http://lists.einsteintoolkit.org/mailman/listinfo/users
>
--
Erik Schnetter <schnetter at cct.lsu.edu>
http://www.perimeterinstitute.ca/personal/eschnetter/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.einsteintoolkit.org/pipermail/users/attachments/20130613/3b745557/attachment.html
More information about the Users
mailing list