Status: New
Owner: ----
New issue 1714 by
nichtess...@gmail.com: C++ Port with Android NDK r8d:
Problem with isnan() in ZXing.h
http://code.google.com/p/zxing/issues/detail?id=1714
What steps will reproduce the problem?
1. Download Release Sourcepackage of ZXing 2.2
2. Copy cpp/core/src/zxing and cpp/core/src/bigint to your JNI-Folder
3. Add the following to Android.mk: LOCAL_C_INCLUDES +=
$(LOCAL_PATH)/<DirectoryWhereZXingFolderIs>
4. When compiling, the g++ runs stops at an error caused by ZXing.h (Line
52)
### What is the expected output? What do you see instead?
I expected the same source-code to compile with the NDK, as id did on my
Desktop (Suse 12.02 with gcc (SUSE Linux) 4.7.1 20120723 [gcc-4_7-branch
revision 189773]). Instead I get the following error (zxing-folder is
located in jni/avcore):
In file included from jni/avcore/zxing/common/BitArray.h:21:0,
from jni/avcore/zxing/common/BitMatrix.h:25,
from jni/avcore/zxing/BinaryBitmap.h:24,
from jni/avcore/zxing/Reader.h:23,
from jni/avcore/zxing/MultiFormatReader.h:24,
from
jni/avcore/featureTagExtractors/ImprovedQRExtractor.cpp:11:
jni/avcore/zxing/ZXing.h:55:13: error: expected unqualified-id
before 'sizeof'
jni/avcore/zxing/ZXing.h:55:13: error: expected ')' before 'sizeof'
jni/avcore/zxing/ZXing.h:55:13: error: expected ')' before 'sizeof'
jni/avcore/zxing/ZXing.h:56:13: error: expected unqualified-id
before 'sizeof'
jni/avcore/zxing/ZXing.h:56:13: error: expected ')' before 'sizeof'
jni/avcore/zxing/ZXing.h:56:13: error: expected ')' before 'sizeof'
make: ***
[obj/local/armeabi/objs-debug/avNative/avcore/featureTagExtractors/ImprovedQRExtractor.o]
Error 1
### What version of the product are you using? On what operating system?
ZXing 2.2 on Android, compiled for Android API 10+ with android-ndk-r8d
### Please provide any additional information below.
A guy states on Stackoverflow that this issue is caused by changes btw. C99
and C++11 compiler implementations. In C99 isnan was defined as a macro,
where it became a function with the same name in standard-namespace in
C++11. Refer
http://stackoverflow.com/questions/8766092/build-issue-when-using-cmath-with-android-ndk
I tried out his suggested solution and it compiled smoothly. Since I'm
running into an issue with iconv.h right now I'm not in a position to
confirm that it is working at runtime as well - I'll report back on that as
soon I fixed the other issue.
What I did was changing this:
#include <cmath>
namespace zxing {
inline bool isnan(float v) {return std::isnan(v);}
inline bool isnan(double v) {return std::isnan(v);}
inline float nan() {return std::numeric_limits<float>::quiet_NaN();}
}
to this - so I simply undefined and removed the std-scopeoperators:
#include <cmath>
#undef isnan
namespace zxing {
inline bool isnan(float v) {return isnan(v);}
inline bool isnan(double v) {return isnan(v);}
inline float nan() {return std::numeric_limits<float>::quiet_NaN();}
}
--
You received this message because this project is configured to send all
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings