我有一个标头SomeDefines.h,它包含
#define U64 unsigned long long
#define U16 unsigned short在Myclass.h中,我在顶部使用#include SomeDefines.h。
在Myclass声明中,我有一个函数
bool someFunc(const std::vector<U64>& theVector);和成员变量tbb::atomic;
当我在Visual Studio 2012中编译时,我得到以下错误
error: 'U64': undeclared identifier
error C2923: 'std::vector': 'U64' is not a valid template type argument for parameter '_Ty'如果我用unsigned long long替换U64,错误就会消失
bool someFunc(const std::vector<unsigned long long>& theVector);我以为编译器会看到#define U64 unsigned long long,并用unsigned long long替换U64。
为什么我在U64而不是U16上收到这些错误
发布于 2015-02-13 17:54:23
对于创建新类型,#define不是一个好主意。首选typedef或using
typedef unsigned long long U64;
// or:
using U64 = unsigned long long;https://stackoverflow.com/questions/28485960
复制相似问题