在一个文件中使用具有相同定义的库

using libraries with the same defines in one file

我有一个项目,我想在其中同时使用 grpc 和 ncurses,但我偶然发现了一个奇怪的错误 我有一个函数

grpc::Status test(){
    ...
    return grpc::Status::OK;
}

在没有 ncurses 的情况下工作正常,但是如果我添加

#include <ncurses.h>

整个事情因这个错误而中断

src/main.cc:32:26: error: expected unqualified-id before ‘(’ token
   32 |     return grpc::Status::OK;
      |                          ^~
make: *** [makefile:34: obj/main.o] Error 1

事实证明,ncurses 也有

#undef OK
#define OK (0)

有没有办法解决这个问题?以下是我的想法,但我不知道如何实施。

我正在编译我的程序:

g++ -lncurses  -lprotobuf -lgrpc++ -lgrpc++_reflection 

看来你可以#undef了。