glassechidna / zxing-cpp

ZXing C++ Library
Apache License 2.0
605 stars 436 forks source link

change cstdlib abs to cmath abs(float). in mingw 4.9.1 abs(in castlib… #15

Closed dushibaiyu closed 9 years ago

dushibaiyu commented 9 years ago

change cstdlib abs to cmath abs. in mingw 4.9.1 abs(in castlib) is erro. funtion abs in cstdlib is : http://www.cplusplus.com/reference/cstdlib/abs/ in cmath is : http://www.cplusplus.com/reference/cmath/abs/

Benjamin-Dobell commented 9 years ago

Could you please elaborate on the reason for the change?

Also, please don't leave commented-out code - just delete the line(s).

dushibaiyu commented 9 years ago

in file /core/src/zxing/pdf417/detector/LinesSampler.cpp in about line 708:
float denom = dxa * dyb - dya * dxb; if(abs(denom) < 1e-12) // Lines don't intersect (replaces "denom == 0") In default it use abs in cstdlib,. funtion abs in cstdlib can't handle abs(float). So , in my build (win7,mingw 4.9.1), there is a erro. I include cmath , replace abs funtion the used to abs(float) in cmath. it is ok.
the action used funtion abs in cstdlib is same to funtion abs in cmath. they are |x|。

Sorry, my english is bad.

Benjamin-Dobell commented 9 years ago

Alright, seems reasonable. Merging...