我正在学习DTMF代码,网址是http://sourceforge.net/projects/dtmf/。我遇到了一些C++代码,但不太理解:
template<int, int, int, int> class Types;
template <> class Types<5, 4, 2, 1>
{
public:
typedef long int Int40;
typedef unsigned long int Uint40;
typedef int Int32;
typedef unsigned int Uint32;
typedef short int Int16;
typedef unsigned short int Uint16;
typedef char Int8;
typedef unsigned char Uint8;
};
template <> class Types<8, 4, 2, 1>
{
public:
typedef long int Int64;
typedef unsigned long int Uint64;
typedef int Int32;
typedef unsigned int Uint32;
typedef short int Int16;
typedef unsigned short int Uint16;
typedef char Int8;
typedef unsigned char Uint8;
};
template <> class Types<4, 4, 2, 1>
{
public:
typedef int Int32;
typedef unsigned int Uint32;
typedef short int Int16;
typedef unsigned short int Uint16;
typedef char Int8;
typedef unsigned char Uint8;
};
// For 16bit chars
template <> class Types<2, 1, 1, 1>
{
public:
typedef long int Int32;
typedef unsigned long int Uint32;
typedef short int Int16;
typedef unsigned short int Uint16;
};
typedef Types<sizeof(long int), sizeof(int), sizeof(short int), sizeof(char)>::Int32 INT32;
typedef Types<sizeof(long int), sizeof(int), sizeof(short int), sizeof(char)>::Uint32 UINT32;
typedef Types<sizeof(long int), sizeof(int), sizeof(short int), sizeof(char)>::Int16 INT16;
typedef Types<sizeof(long int), sizeof(int), sizeof(short int), sizeof(char)>::Uint16 UINT16;
从那里开始,它们就像普通的原始类型一样使用:
static const INT16 tempCoeff[8];
我的直觉告诉我,这些东西可以在不同平台之间实现一定的可移植性。我是对的,还是还有其他方面?
<stdint.h>
呢? - Paul Rstdint.h
。 - Mark Blong
?我想知道那是什么样的机器。 - Robᵩ