【发布时间】:2013-08-05 13:23:52
【问题描述】:
我已经按照安装说明安装了mimetic 库。
以下主文件使用gcc-c++ 4.1.2 编译没有问题,
但是当我升级到gcc-c++ 4.4.7 时出现错误。
模拟.cpp:
#include <iostream>
#include <mimetic.h>
using namespace std;
using namespace mimetic;
int main()
{
MimeEntity me;
return 0;
}
错误
In file included from /usr/local/include/mimetic/rfc822/header.h:18,
from /usr/local/include/mimetic/header.h:11,
from /usr/local/include/mimetic/mimetic.h:18,
from mimetic.cpp:2:
/usr/local/include/mimetic/rfc822/messageid.h:29: error: expected ‘)’ before ‘thread_id’
头文件: rfc822/messageid.h
#ifndef _MIMETIC_MESSAGEID_H_
#define _MIMETIC_MESSAGEID_H_
#ifdef HAVE_STDINT_H
#include <stdint.h>
#endif
#include <string>
#include <mimetic/libconfig.h>
#ifdef HAVE_INTTYPES_H
#include <inttypes.h>
#endif
#include <mimetic/utils.h>
#include <mimetic/os/utils.h>
#include <mimetic/rfc822/fieldvalue.h>
namespace mimetic
{
/// Message-ID field value
/// On Win32 Winsock library must be initialized before using this class.
struct MessageId: public FieldValue
{
MessageId(uint32_t thread_id = 0 ); // <------ line 29
MessageId(const std::string&);
std::string str() const;
void set(const std::string&);
protected:
FieldValue* clone() const;
private:
static unsigned int ms_sequence_number;
std::string m_msgid;
};
}
#endif
gcc 是否有一些兼容性开关?
【问题讨论】:
-
我怀疑你的
HAVE_STDINT_H或HAVE_INTTYPES_H是“错误的”,所以你没有得到uint32_t。 -
@Mats Petersson 如何检查这些是否正确?
-
尝试在
HAVE_STDINT_H中添加下一个#error this should give an error,开始。如果您没有收到错误,则未设置HAVE_STDINT_H- 我很确定它应该是 [虽然从技术上讲,因为它是 C++ 代码,它确实应该使用cstdint- 但我怀疑它是否会产生区别]。 -
您可以尝试将 -DHAVE_STDINT_H 添加到 gcc 的参数中,看看它是否有效。确保设置标志的正确方法取决于您的构建系统。
-
另外,如果您的系统缺少
stdint.h,您需要有提供适当typedefs 的替换代码,或者根据@定义您自己的抽象类型987654336@ 类型(如果存在)或系统特定类型(如果不存在)。就cstdint而言,我使用过提供stdint.h但不提供cstdint的C++ 编译器......