由于某种原因,当我编译我的代码时,编译器找不到 fsync 和 truncate 的原型。我明白了:
cc -c -Wall -Wno-overflow -pedantic -std=c99 -I/Users/matt/Programming/BitEagle_Projects/cbitcoin/include -I/usr/local/ssl/include -I/opt/local/include -O3 -arch i386 -arch x86_64 -D_POSIX_SOURCE -fPIC dependencies/storage/CBBlockChainStorage.c -o build/CBBlockChainStorage.o
dependencies/storage/CBBlockChainStorage.c:154:6: warning: implicit declaration of function 'fsync'
is invalid in C99 [-Wimplicit-function-declaration]
if(fsync(indexAppend)){
^
dependencies/storage/CBBlockChainStorage.c:649:6: warning: implicit declaration of function
'truncate' is invalid in C99 [-Wimplicit-function-declaration]
if (truncate(filename, CBArrayToInt32(data, 0))) {
^
我该怎么做才能删除这些警告?我包括 unistd.h。这是在 OSX 上使用 clang:
$ cc --version
Apple clang version 4.0 (tags/Apple/clang-421.0.60) (based on LLVM 3.1svn)
Target: x86_64-apple-darwin12.2.0
Thread model: posix
谢谢你。