我有一个包含
的标题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 someNumber;
当我在Visual Studio 2012中编译时,我得到了错误
error: 'U64': undeclared identifier
error C2923: 'std::vector': 'U64' is not a valid template type argument for parameter '_Ty'
如果我将U64
替换为unsigned long long
bool someFunc(const std::vector<unsigned long long>& theVector);
我认为编译器会看到#define U64 unsigned long long
并将U64
替换为unsigned long long
。
为什么我会为U64
而不是U16
答案 0 :(得分:0)
#define
不是创建新类型的好主意。首选typedef
或using
:
typedef unsigned long long U64;
// or:
using U64 = unsigned long long;