Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
将一些遗留 C 代码从 QNX(Photon C 编译器)移植到 Linux (GCC)。在几个地方我看到这样的代码:
void process_data(char key, char *data) { int i; /* Required for compilation */ i=i; key=key; data=data; ... }
显然,编译不需要此代码,它什么也不做。
我的问题是,你为什么一开始会这样做?
这消除了关于未引用变量的编译警告/错误。通常这样的东西要么通过#pragmas 要么通过更具表现力的形式来完成,例如宏:#define unused_var(x) (x)=(x)
#pragma
#define unused_var(x) (x)=(x)