I have a header SomeDefines.h that includes
我有一个标题。h,包括
#define U64 unsigned long long
#define U16 unsigned short
In Myclass.h, I #include SomeDefines.h
at the top.
在Myclass。我# include SomeDefines h。h在顶部。
In the Myclass declaration, I have a function
在Myclass声明中,我有一个函数。
bool someFunc(const std::vector<U64>& theVector);
and a member variable tbb::atomic someNumber;
以及一个成员变量tbb::atomic someNumber;
When I compile in Visual Studio 2012, I get the errors
当我在Visual Studio 2012中编译时,我得到了错误。
error: 'U64': undeclared identifier
error C2923: 'std::vector': 'U64' is not a valid template type argument for parameter '_Ty'
The errors go away if I replace the U64
with unsigned long long
如果我用unsigned long long替换U64,错误就会消失。
bool someFunc(const std::vector<unsigned long long>& theVector);
I thought the compiler would see the #define U64 unsigned long long
and replace U64
with unsigned long long
.
我认为编译器会看到#define U64没有签名的long long,并且用unsigned long long替换U64。
Why am I getting these errors for the U64
and not the U16
?
为什么我要为U64而不是U16得到这些错误?
1 个解决方案
#1
0
#define
is not a good idea for creating new types. Prefer typedef
or using
:
#define不是创建新类型的好方法。喜欢的类型或使用:
typedef unsigned long long U64;
// or:
using U64 = unsigned long long;
#1
0
#define
is not a good idea for creating new types. Prefer typedef
or using
:
#define不是创建新类型的好方法。喜欢的类型或使用:
typedef unsigned long long U64;
// or:
using U64 = unsigned long long;