gpt4 book ai didi

c - 编译时访问的文件列表

转载 作者:太空宇宙 更新时间:2023-11-04 07:18:53 25 4
gpt4 key购买 nike

我正在用 C 编译一个巨大的项目,但我认为有很多文件没有被使用。有什么办法,我可以获得编译期间正在使用/访问的文件列表。

最佳答案

这取决于编译器。使用 GCC,您可以使用 -H 获取包含的所有文件的列表。例如,我有一个文件 itobase.c,它在指定 -DTEST 时编译为程序。

来源包含:

#include <assert.h>
#include <string.h>
#include <unistd.h>
#include <inttypes.h>
#include "stderr.h"

…code…

#include <stdio.h>
#include <stdlib.h>

…test code…

使用 -H 选项,gcc 生成:

$ gcc -I. -H -DHAVE_CONFIG_H -DJLSS_STDERR -O2 -fPIC -g -std=c99 -pedantic -Wall \
> -Wshadow -Wpointer-arith -Wstrict-prototypes -Wmissing-prototypes -Werror \
> -DTEST -o itobase itobase.c /Users/jleffler/lib/64/libjl.a
. /usr/include/assert.h
.. /usr/include/sys/cdefs.h
... /usr/include/sys/_symbol_aliasing.h
... /usr/include/sys/_posix_availability.h
. /usr/include/string.h
.. /usr/include/_types.h
... /usr/include/sys/_types.h
.... /usr/include/machine/_types.h
..... /usr/include/i386/_types.h
.. /usr/include/Availability.h
... /usr/include/AvailabilityInternal.h
.. /usr/include/sys/_types/_size_t.h
.. /usr/include/sys/_types/_null.h
.. /usr/include/sys/_types/_ssize_t.h
.. /usr/include/strings.h
... /usr/include/string.h
.. /usr/include/secure/_string.h
... /usr/include/secure/_common.h
. /usr/include/unistd.h
.. /usr/include/sys/unistd.h
... /usr/include/sys/_types/_posix_vdisable.h
... /usr/include/sys/_types/_seek_set.h
.. /usr/include/sys/_types/_gid_t.h
.. /usr/include/sys/_types/_intptr_t.h
.. /usr/include/sys/_types/_off_t.h
.. /usr/include/sys/_types/_pid_t.h
.. /usr/include/sys/_types/_uid_t.h
.. /usr/include/sys/_types/_useconds_t.h
.. /usr/include/sys/select.h
... /usr/include/sys/appleapiopts.h
... /usr/include/sys/_types/_fd_def.h
... /usr/include/sys/_types/_timespec.h
... /usr/include/sys/_types/_timeval.h
... /usr/include/sys/_types/_time_t.h
... /usr/include/sys/_types/_suseconds_t.h
... /usr/include/sys/_types/_sigset_t.h
... /usr/include/sys/_types/_fd_setsize.h
... /usr/include/sys/_types/_fd_set.h
... /usr/include/sys/_types/_fd_clr.h
... /usr/include/sys/_types/_fd_isset.h
... /usr/include/sys/_types/_fd_zero.h
... /usr/include/sys/_types/_fd_copy.h
... /usr/include/sys/_select.h
.. /usr/include/sys/_types/_dev_t.h
.. /usr/include/sys/_types/_mode_t.h
.. /usr/include/sys/_types/_uuid_t.h
.. /usr/include/gethostuuid.h
. /usr/include/inttypes.h
.. /usr/include/sys/_types/_wchar_t.h
.. /usr/gcc/v4.8.2/lib/gcc/x86_64-apple-darwin12.5.0/4.8.2/include/stdint.h
... /usr/gcc/v4.8.2/lib/gcc/x86_64-apple-darwin12.5.0/4.8.2/include-fixed/stdint.h
. stderr.h
.. config.h
.. /usr/include/stdio.h
... /usr/include/sys/_types/_va_list.h
... /usr/include/secure/_stdio.h
.. /usr/gcc/v4.8.2/lib/gcc/x86_64-apple-darwin12.5.0/4.8.2/include/stdarg.h
. /usr/include/stdlib.h
.. /usr/include/sys/wait.h
... /usr/include/sys/_types/_id_t.h
... /usr/include/sys/signal.h
.... /usr/include/machine/signal.h
..... /usr/include/i386/signal.h
.... /usr/include/machine/_mcontext.h
..... /usr/include/i386/_mcontext.h
...... /usr/include/mach/i386/_structs.h
.... /usr/include/sys/_types/_sigaltstack.h
.... /usr/include/sys/_types/_ucontext.h
.... /usr/include/sys/_types/_pthread_attr_t.h
... /usr/include/sys/resource.h
... /usr/include/machine/endian.h
.... /usr/include/i386/endian.h
..... /usr/include/sys/_endian.h
...... /usr/include/libkern/_OSByteOrder.h
....... /usr/include/libkern/i386/_OSByteOrder.h
.. /usr/include/alloca.h
.. /usr/include/sys/_types/_ct_rune_t.h
.. /usr/include/sys/_types/_rune_t.h
.. /usr/include/sys/_types/_wchar_t.h
.. /usr/include/machine/types.h
... /usr/include/i386/types.h
.... /usr/include/sys/_types/_int8_t.h
.... /usr/include/sys/_types/_int16_t.h
.... /usr/include/sys/_types/_int32_t.h
.... /usr/include/sys/_types/_int64_t.h
.... /usr/include/sys/_types/_uintptr_t.h
.... /usr/include/sys/_types/___offsetof.h
Multiple include guards may be useful for:
/usr/include/assert.h
/usr/include/machine/_mcontext.h
/usr/include/secure/_stdio.h
/usr/include/secure/_string.h
/usr/include/sys/_posix_availability.h
/usr/include/sys/_symbol_aliasing.h
config.h
$

前面有一个点的名称是直接包含在源中的名称。其余的是从直接包含的文件中间接包含的。

在 Mac OS X 10.9.2 上使用 GCC 4.8.2 编译。

关于c - 编译时访问的文件列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22653623/

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