2012-11-01 62 views
0

我建立使用MinGW的斑马线声明,但它失败,这些错误:错误:“srandom”没有在此范围

build\core\tests\src\common\BitArrayTest.cpp: In static member function 'static void zxing::BitArrayTest::fillRandom(zxing::BitArray&, zxing::BitArray&)': 
build\core\tests\src\common\BitArrayTest.cpp:99:39: error: 'srandom' was not declared in this scope 
build\core\tests\src\common\BitArrayTest.cpp:101:15: error: 'random' was not declared in this scope 
scons: *** [build\core\tests\src\common\BitArrayTest.o] Error 1 

我尝试添加-DANN_NO_RANDOM到编译器标志,但事实并非如此帮帮我。

+1

你的意思是['rand'](http://www.cplusplus.com/reference/clibrary/cstdlib/rand/)和['srand'](http://www.cplusplus.com/reference/) clibrary/cstdlib /函数srand /)? – jrok

+0

不,zxing的代码真的使用[srandom和random](http://linux.about.com/library/cmd/blcmdl3_srandom.htm)。 – sashoalm

回答

6

srandomlinux功能,转而使用srand,如果你不想改变从外部库中的代码,只需添加-Dsrandom=srand -Drandom=rand到编译器标志。

+2

它实际上在[POSIX](http://pubs.opengroup.org/onlinepubs/009695399/functions/srandom.html)中指定,这意味着所有UNIX或类UNIX环境都应该有它。 –

0

您需要包含<stdlib.h>头文件。