【发布时间】:2013-01-12 13:27:35
【问题描述】:
我在名为RaftLog.cc 的文件中有以下代码:
#include <algorithm>
#include <fcntl.h>
#include <sys/stat.h>
namespace LogCabin {
namespace Server {
namespace RaftConsensusInternal {
namespace FilesystemUtil = Storage::FilesystemUtil;
namespace {
bool
fileToProto(const std::string& path, google::protobuf::Message& out)
{
int fd = open(path.c_str(), O_RDONLY);
if (fd == -1)
return false;
else
close(fd);
FilesystemUtil::FileContents file(path);
// more code down here, not useful to the problem.
但是,当我编译时,我有:
build/Server/RaftLog.cc: In function ‘bool LogCabin::Server::RaftConsensusInternal::{anonymous}::fileToProto(const string&, google::protobuf::Message&)’:
build/Server/RaftLog.cc:43:17: error: ‘close’ was not declared in this scope
build/Server/RaftLog.cc: In function ‘void LogCabin::Server::RaftConsensusInternal::{anonymous}::protoToFile(google::protobuf::Message&, const string&)’:
build/Server/RaftLog.cc:76:13: error: ‘close’ was not declared in this scope
In file included from ./Server/RaftConsensus.h:17:0,
我不知道为什么#include <fcntl.h> 没有包含close() 函数。有人可以帮助我吗?如果我应该包含更多代码,也请告诉我。
【问题讨论】: