2012-11-01 66 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>頭文件。