预处理器#define T导致Xcode错误

时间:2014-04-11 04:20:51

标签: c++ xcode c-preprocessor

每当我在我的代码中使用#define T时,我得到的是与Xcode使用的type_traits文件相关的19个错误。我把它放在我的一个头文件中的一行。这是头文件:

#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

如果我更改T的名称或者不包含所有错误就会消失。我无法真正发布带有错误的文件,因为它长达1000行。它的名字是&#34; type_traits&#34;大多数错误都是这样的:

  

在&#39; typename&#39;

之后需要一个合格的名字

1 个答案:

答案 0 :(得分:1)

使用时

#define T 0x101 

您可以将包含标题的文件中使用的每个T字母替换为0x101

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