Typedef 不是命名空间的成员
Typedef not a member of namespace
因此,我尝试分叉一些开源代码,但在编译时遇到了这些错误:
C2039 'TransactionId': is not a member of 'CryptoNote'
C2061 syntax error: identifier 'TransactionId'
我对C++
比较缺乏经验,通常把自己局限于C#
的领域,但是,我可以清楚地看到TransactionId
是一个typedef
声明在像这样的不同文件:
namespace CryptoNote {
typedef size_t TransactionId;
typedef size_t TransferId;
//more code
而抛出错误的行是:
void sendTransactionCompleted(CryptoNote::TransactionId _id, bool _error, const QString& _error_text);
在我这个没有经验的人看来,TransactionID
确实是 Cryptonote
的成员,不是吗?
知道发生了什么事吗?
没有看到所有代码就很难说,但我想到了一些事情:
首先,这是您遇到的第一个错误。 C++ 的编译错误往往会导致一堆次要错误。例如,以下结果会导致与您看到的类似的错误,但无法编译,因为 size_t
尚未定义:
命名空间 CryptoNote {
typedef size_t 事务编号;
typedef size_t TransferId;
}
int main(void)
{
CryptoNote::TransactionId 编号;
return0;
}
$ g++ -std=c++11 namespace.cxx -o 命名空间
namespace.cxx:4:9: 错误:‘size_t’没有命名类型
typedef size_t 事务编号;
^~~~~~
namespace.cxx:5:9: 错误:‘size_t’没有命名类型
typedef size_t TransferId;
^~~~~~
namespace.cxx: 在函数‘int main()’中:
namespace.cxx:11:17: 错误:“TransactionId”不是“CryptoNote”的成员
CryptoNote::TransactionId 编号;
^~~~~~~~~~~~~
有关定义 size_t
的 header 的列表,请参阅 http://www.cplusplus.com/reference/cstring/size_t/。
CryptoNote
是否嵌套在另一个命名空间中?
- 是否在声明函数的命名空间中定义了另一个
CryptoNote
?
- 这些在同一个 header 文件中吗?如果不是,定义命名空间的header文件是否包含在包含函数声明的header文件中?
这些 typedef 在 Incendium_Crypt/include/IWalletLegacy.h
中定义。
void sendTransactionCompleted(CryptoNote::TransactionId _id, bool _error, const QString& _error_text);`
在 Incendium_GUI/src/gui/SendFrame.h
中定义,其中包括 IWallet.h
。但是,IWallet.h
而不是 又包含 IWalletLegacy.h
。因此,这些 typedef 对 SendFrame.h
.
是未知的
因此,我尝试分叉一些开源代码,但在编译时遇到了这些错误:
C2039 'TransactionId': is not a member of 'CryptoNote'
C2061 syntax error: identifier 'TransactionId'
我对C++
比较缺乏经验,通常把自己局限于C#
的领域,但是,我可以清楚地看到TransactionId
是一个typedef
声明在像这样的不同文件:
namespace CryptoNote {
typedef size_t TransactionId;
typedef size_t TransferId;
//more code
而抛出错误的行是:
void sendTransactionCompleted(CryptoNote::TransactionId _id, bool _error, const QString& _error_text);
在我这个没有经验的人看来,TransactionID
确实是 Cryptonote
的成员,不是吗?
知道发生了什么事吗?
没有看到所有代码就很难说,但我想到了一些事情:
首先,这是您遇到的第一个错误。 C++ 的编译错误往往会导致一堆次要错误。例如,以下结果会导致与您看到的类似的错误,但无法编译,因为
size_t
尚未定义:命名空间 CryptoNote {
typedef size_t 事务编号; typedef size_t TransferId;
}
int main(void) { CryptoNote::TransactionId 编号; return0; }
$ g++ -std=c++11 namespace.cxx -o 命名空间 namespace.cxx:4:9: 错误:‘size_t’没有命名类型 typedef size_t 事务编号; ^~~~~~ namespace.cxx:5:9: 错误:‘size_t’没有命名类型 typedef size_t TransferId; ^~~~~~ namespace.cxx: 在函数‘int main()’中: namespace.cxx:11:17: 错误:“TransactionId”不是“CryptoNote”的成员 CryptoNote::TransactionId 编号; ^~~~~~~~~~~~~
有关定义 size_t
的 header 的列表,请参阅 http://www.cplusplus.com/reference/cstring/size_t/。
CryptoNote
是否嵌套在另一个命名空间中?- 是否在声明函数的命名空间中定义了另一个
CryptoNote
? - 这些在同一个 header 文件中吗?如果不是,定义命名空间的header文件是否包含在包含函数声明的header文件中?
这些 typedef 在 Incendium_Crypt/include/IWalletLegacy.h
中定义。
void sendTransactionCompleted(CryptoNote::TransactionId _id, bool _error, const QString& _error_text);`
在 Incendium_GUI/src/gui/SendFrame.h
中定义,其中包括 IWallet.h
。但是,IWallet.h
而不是 又包含 IWalletLegacy.h
。因此,这些 typedef 对 SendFrame.h
.