c++ - 我可以在处理它时保留编译器输出的格式吗?

标签 c++ bash redirect gcc formatting

每当我调用 run GCC 时,它都会很好地格式化其输出(使文件名加粗、注释标签为白色、错误标签为红色等)。但是,当我想重定向它并仍然保持显示时,格式就消失了......

例子:

make                                    # The display is formatted
(...)
make |& tee >(xargs echo > example.out) # The display is not formatted
(...)

如何在保持原始显示格式的同时重定向输出?

最佳答案

文档说(文件:gcc-6.info,节点:诊断消息格式化选项):

-fdiagnostics-color[=WHEN]

Use color in diagnostics. WHEN is never, always, or auto. The default depends on how the compiler has been configured, it can be any of the above WHEN options or also never if GCC_COLORS environment variable isn't present in the environment, and auto otherwise. auto means to use color only when the standard error is a terminal.

关于c++ - 我可以在处理它时保留编译器输出的格式吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40767475/

相关文章:

bash - 通过 xargs 连接带有变量的字符串

php - 默认 404 错误页面而不是自定义?

codeigniter - 使用 Codeigniter 重定向 SEO 友好的 url?

grails - 如果 grails 中验证失败则返回同一页面

c++ - 如何处理模板类中的指针?

c++ - 将 mtrace 用于 c++

string - 输出shell变量时如何保留空格?

C++ CreateProcess() 在与第一个相同的窗口中运行

c++ - 二维数组的简单替代品

Linux bash 文件 : RENAME subdirs by count of files in them