typedef未解析的外部符号

时间:2013-07-07 04:04:07

标签: c++ visual-studio

调用类构造函数时,我得到了错误未解析的外部符号。构造函数声明为:

// #include header files

class Constant
{
    Constant(boost::uint16_t featureID, boost::uint32_t featureValue);
}

该定义位于另一个.cpp文件中:

// #include header files

Constant::Constant(boost::uint16_t featureID,  boost::uint32_t featureValue)
{
    m_featureID = featureID;
    m_featureValue = featureValue;
}

可以成功构建Constant类的源/头文件。但是当我从另一个文件调用Constant()时,它出错了。

Constant dfObj1 = Constant(0, 1); // error LNK2019: unresolved external symbol "public: __thiscall pClickDLL::Constant::Constant(unsigned short, unsigned long)

奇怪的是当我在Constant类的源/头文件中将boost::uint16_t更改为unsigned shortboost::uint32_t更改为unsigned int时,它没有问题。

我猜错误是由于某些类型重新定义的错误导致的,例如头文件中的boost::uint16_t表示类型,但源文件中的另一种类型(例如,boost::uint16_t可能意味着{{1}在头文件中,但在源文件中可能是unsigned short。当我在Constant类的源/头文件中包含不同的头文件,并且头文件typedef不同时,可能会发生这种情况。但我不明白为什么它发生在这里,因为我已经在类型之前放置了命名空间。 unsigned int应始终在Constant类的源/头文件中表示相同的类型。不是吗?

更新:问题是我为两个项目使用了不同的boost库。我使用boost 1.42作为Constant类的项目,并为调用文件的项目提升1.53。

0 个答案:

没有答案