[Genabel-commits] r1361 - in pkg/filevector: . fvfutil fvlib tests
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Wed Nov 6 14:19:51 CET 2013
Author: lckarssen
Date: 2013-11-06 14:19:49 +0100 (Wed, 06 Nov 2013)
New Revision: 1361
Modified:
pkg/filevector/Makefile
pkg/filevector/fvfutil/convert.cpp
pkg/filevector/fvlib/CastUtils.cpp
pkg/filevector/tests/WriteVariablesSpeed.cpp
Log:
Compile filevector using the -std=c++11 option. This hopefully fixes
the comments in this mail by Prof. Ripley:
http://lists.r-forge.r-project.org/pipermail/genabel-devel/2013-November/000766.html
Makefile: add -std=c++11 to CFLAGS
fvlib/CastUtils.cpp: Fix (what I think is) the error that aborts the
compilation mention in the e-mail. The error message after compiling
with the updated Makefile is listed at the end of this
message. Basically it complains that there is an ambiguous definition
of the bool isnan(double) function. The <cmath> header puts its
definitions in the std namespace, so the fix I applied simply
explicitely calls the isnan() function from std.
fvfutil/convert.cpp: adding -Wall to the Makefile gave an error about
comparing an int and an unsigned int. To fix this I decided to cast
the file size (st_size) to an unsigned int. I think that's safe to
do.
tests/WriteVariablesSpeed.cpp: another error because of the -Wall
option. Again comparing int and unsigned int. Here the fix is
trivial.
Compile error (mentioned above):
g++ -I fvlib -I fvfutil -g -Wall -std=c++11 -lcppunit fvlib/*.cpp fvfutil/text2fvf.cpp fvfutil/convert.cpp -o bin/convert
fvlib/CastUtils.cpp: In function ?\226?\128?\152bool checkNan(void*, int)?\226?\128?\153:
fvlib/CastUtils.cpp:189:46: error: call of overloaded ?\226?\128?\152isnan(double&)?\226?\128?\153 is ambiguous
return isnan( *static_cast<double*>(data) );
^
fvlib/CastUtils.cpp:189:46: note: candidates are:
In file included from /usr/include/features.h:371:0,
from /usr/include/x86_64-linux-gnu/c++/4.8/bits/os_defines.h:39,
from /usr/include/x86_64-linux-gnu/c++/4.8/bits/c++config.h:426,
from /usr/include/c++/4.8/bits/stl_algobase.h:59,
from /usr/include/c++/4.8/bits/stl_tree.h:61,
from /usr/include/c++/4.8/map:60,
from fvlib/CastUtils.cpp:1:
/usr/include/x86_64-linux-gnu/bits/mathcalls.h:235:1: note: int isnan(double)
__MATHDECL_1 (int,isnan,, (_Mdouble_ __value)) __attribute__ ((__const__));
^
In file included from fvlib/CastUtils.cpp:4:0:
/usr/include/c++/4.8/cmath:626:3: note: constexpr bool std::isnan(long double)
isnan(long double __x)
^
/usr/include/c++/4.8/cmath:622:3: note: constexpr bool std::isnan(double)
isnan(double __x)
^
/usr/include/c++/4.8/cmath:618:3: note: constexpr bool std::isnan(float)
isnan(float __x)
^
fvfutil/convert.cpp: In function ?\226?\128?\152int main(int, char**)?\226?\128?\153:
fvfutil/convert.cpp:36:43: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if (filestatus.st_size < sizeof(data_type))
^
make: *** [bin/convert] Error 1
Modified: pkg/filevector/Makefile
===================================================================
--- pkg/filevector/Makefile 2013-11-04 10:10:43 UTC (rev 1360)
+++ pkg/filevector/Makefile 2013-11-06 13:19:49 UTC (rev 1361)
@@ -29,7 +29,7 @@
# use for Solaris
# CPP = CC
-CFLAGS = -I $(LIBDIR) -I $(SRCDIR) -g #-m64
+CFLAGS = -I $(LIBDIR) -I $(SRCDIR) -g -Wall -std=c++11 #-m64
CPPUNITFLAGS = -lcppunit
EXECS = $(TEXT2FVF) $(MERGEVARS) ${CONVERT}
Modified: pkg/filevector/fvfutil/convert.cpp
===================================================================
--- pkg/filevector/fvfutil/convert.cpp 2013-11-04 10:10:43 UTC (rev 1360)
+++ pkg/filevector/fvfutil/convert.cpp 2013-11-06 13:19:49 UTC (rev 1361)
@@ -33,7 +33,7 @@
stat( filename.c_str() , &filestatus);
- if (filestatus.st_size < sizeof(data_type))
+ if ( (unsigned int) filestatus.st_size < sizeof(data_type) )
errorLog << "File " << filename <<" is too short to contain an FVF-object." << endl << errorExit;
fstream dataFile;
@@ -86,4 +86,4 @@
new_index_file.close();
delete buffer;
-}
\ No newline at end of file
+}
Modified: pkg/filevector/fvlib/CastUtils.cpp
===================================================================
--- pkg/filevector/fvlib/CastUtils.cpp 2013-11-04 10:10:43 UTC (rev 1360)
+++ pkg/filevector/fvlib/CastUtils.cpp 2013-11-06 13:19:49 UTC (rev 1361)
@@ -184,9 +184,9 @@
case INT:
return (*(int*) data) == INT_NAN;
case FLOAT:
- return isnan(*(float*) data);
+ return std::isnan(*(float*) data);
case DOUBLE:
- return isnan(*(double*) data);
+ return std::isnan(*(double*)data);
case UNSIGNED_CHAR:
return (*(unsigned char*) data) == UNSIGNED_CHAR_NAN;
case SIGNED_CHAR:
Modified: pkg/filevector/tests/WriteVariablesSpeed.cpp
===================================================================
--- pkg/filevector/tests/WriteVariablesSpeed.cpp 2013-11-04 10:10:43 UTC (rev 1360)
+++ pkg/filevector/tests/WriteVariablesSpeed.cpp 2013-11-06 13:19:49 UTC (rev 1361)
@@ -35,7 +35,7 @@
FileVector fv(filename,cache_size);
float * tmp = new float[fv.getNumObservations()];
- for(int i=0;i<fv.getNumVariables();i++)
+ for(unsigned int i=0;i<fv.getNumVariables();i++)
{
fv.writeVariable(i, tmp);
fv.writeVariableName(i,FixedChar("original"));
@@ -60,4 +60,4 @@
delete[] tmp;
-}
\ No newline at end of file
+}
More information about the Genabel-commits
mailing list