1

我认为每件事都在标题中^^ 事实上,我正在使用 libtooling 开发一个工具,但我想抑制每个错误(该工具旨在仅用于正确的源,因此错误输出会影响标准错误。 ..)。

4

2 回答 2

4

标题是 libclang/libtooling,所以这里是 libclang 的答案。像这样创建你的CXIndex

bool excludeDeclarationsFromPCH = false;
bool displayDiagnostics = false;
CXIndex index = clang_createIndex((int)excludeDeclarationsFromPCH, (int)displayDiagnostics);

请参阅文档

于 2014-04-28T15:23:26.797 回答
0

你想重定向你的std::cerr输出吗?还是stderr每个子进程?如果是后一种情况,您可以执行以下操作:

#include <unistd.h>

int fd = dup(2);
int n = open("/dev/null", O_WRONLY);
dup2(n, 2);
close(n);

//... do your thing ...

dup2(fd, 2); // put the stderr back where it belongs :D
close(fd);
于 2014-04-28T14:47:19.097 回答