gpt4 book ai didi

c++ - `gcc -E -P -C` 添加额外注释

转载 作者:太空狗 更新时间:2023-10-29 20:40:11 25 4
gpt4 key购买 nike

我正在尝试在包含注释的 JS 文件上运行 CPP。我想保留评论,所以我使用 gcc -E -P-C 参数,但是 GCC 或 CPP 然后添加了额外的评论。重现方法如下:

➜  cpp-test  ls
➜ cpp-test touch empty
➜ cpp-test gcc -E -P -x assembler-with-cpp -C empty -o empty.out
➜ cpp-test cat empty.out
/* Copyright (C) 1991-2013 Free Software Foundation, Inc.
This file is part of the GNU C Library.

The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
/* This header is separate from features.h so that the compiler can
include it implicitly at the start of every compilation. It must
not itself include <features.h> or any other header that includes
<features.h> because the implicit include comes before any feature
test macros that may be defined in a source file before it first
explicitly includes a system header. GCC knows the name of this
header in order to preinclude it. */
/* We do support the IEC 559 math functionality, real and complex. */
/* wchar_t uses ISO/IEC 10646 (2nd ed., published 2011-03-15) /
Unicode 6.0. */
/* We do not support C11 <threads.h>. */
➜ cpp-test

我如何告诉 GCC/CPP 不要生成这些评论?

最佳答案

注释似乎包含了对正在发生的事情的解释,特别是说编译器可以在每次编译开始时隐式包含它并且GCC知道这个头文件的名称的部分为了预先包含它

有一个 gcc bug report这看起来与您通过使用 -nostdinc 解决的问题非常相似。

关于c++ - `gcc -E -P -C` 添加额外注释,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25118052/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com