Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/163.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 预处理器#定义T导致Xcode错误_C++_Xcode_C Preprocessor - Fatal编程技术网

C++ 预处理器#定义T导致Xcode错误

C++ 预处理器#定义T导致Xcode错误,c++,xcode,c-preprocessor,C++,Xcode,C Preprocessor,每当我在代码中使用#define T时,我都会收到大约19个与Xcode使用的type#u traits文件相关的错误。我已经在我的一个头文件中将它降低到一行。以下是头文件: #ifndef __SlidingWindowCompression__Utils__ #define __SlidingWindowCompression__Utils__ // DEFINITIONS: #define CONT_FLAG 0x00 #define STOP_FLAG 0xFF #define BYT

每当我在代码中使用#define T时,我都会收到大约19个与Xcode使用的type#u traits文件相关的错误。我已经在我的一个头文件中将它降低到一行。以下是头文件:

#ifndef __SlidingWindowCompression__Utils__
#define __SlidingWindowCompression__Utils__

// DEFINITIONS:
#define CONT_FLAG 0x00
#define STOP_FLAG 0xFF
#define BYTE_SIZE 8
#define A_KEY 0x000
#define T_KEY 0x001
#define G_KEY 0x010
#define C_KEY 0x100
#define N_KEY 0x011
#define A 0x100
#define T 0x101 //ERROR RIGHT HERE WHEN INCLUDED!!!
#define G 0x110
#define C 0x111

// INCLUDES:
#include <iostream>
#include <fstream>
#include <vector>
#include <cstdint>

// FUNCTION DECLERATIONS:
std::string getKey(std::ifstream& inStream);
int  getReadSize(std::ifstream& inStream);
void outputHeader(const int READ_SIZE, const std::string& KEY, std::ofstream& outStream);
bool setRead(std::string& read, std::ifstream& inStream);
void stuffit(unsigned char value, int bits, int endFlag, std::ofstream& outStream);
void setIndexAndBitset(const std::string& KEY, std::string& read, uint16_t& index, std::vector<int>& bits);
unsigned char getHex(const char readChar, const char keyChar);

#endif
\ifndef\uu滑动窗口压缩\uuu实用程序__
#定义滑动窗口压缩工具__
//定义:
#定义CONT_标志0x00
#定义停止标志0xFF
#定义字节大小8
#定义一个_键0x000
#定义T_键0x001
#定义G_键0x010
#定义C_键0x100
#定义N_键0x011
#定义一个0x100
#定义T 0x101//包含时,错误就在这里!!!
#定义g0x110
#定义c0x111
//包括:
#包括
#包括
#包括
#包括
//功能减退:
std::string getKey(std::ifstream和inStream);
int getReadSize(标准::ifstream和inStream);
void输出头(const int READ_SIZE,const std::string&KEY,std::of stream&outStream);
bool setRead(std::string&read,std::ifstream&inStream);
void stuffit(无符号字符值、int位、int-endFlag、std::ofstream&outStream);
void setIndexAndBitset(常量std::string和KEY,std::string和read,uint16\u t和index,std::vector和bits);
无符号字符getHex(常量字符readChar,常量字符keyChar);
#恩迪夫
如果我更改了T的名称或没有包含所有错误,那么所有错误都会消失。我真的不能发布带有错误的文件,因为它有1000行长。它的名字是“type_traits”,大多数错误如下:

“typename”后应为限定名

当你使用

#define T 0x101 
替换0x101包含头的文件中使用的每个T字母


更好的解决方案是使用枚举而不是定义。

您使用的是枚举。无论如何,
T
在模板中经常用作类型名。更改它对任何使用它的模板都不起作用。请尽可能避免
#define
。用
const int
或其他东西替换它们。您能详细说明一下我为什么不想使用#defines吗?您是说将它们全局声明为const int吗?