确定包含的库标头使用哪个预处理器定义

时间:2018-05-03 09:14:07

标签: c build c-preprocessor autotools configure

我正在查看一个项目,该项目在config.h中由autotools生成了许多预处理器定义。

现在,其中一些来自早期版本的源代码,也来自部分内容已被切除,源文件不再存在。所以 - 一些文件现在没用了,不应该生成。问题是 - 哪一部分?

您可以做的一件事是在当前项目源中搜索预处理器定义的使用。我做到了。但是 - 有一些定义会在包含时影响其他库的标题,例如_GNU_SOURCE

我的问题:如何确定哪些定义(包括当前在config.h中注释掉的定义)在源代码中包含的标题有可能?

(当然我在这里需要精确回忆,因为无用的#define并不是那么糟糕,但是我真的需要避免缺少定义。)

1 个答案:

答案 0 :(得分:0)

最简单的方法是让$ cd myCproject $ autoscan aclocal.m4:16: warning: this file was generated for autoconf 2.63. You have another version of autoconf. It may work, but is not guaranteed to. If you have problems, you may need to regenerate the build system entirely. To do so, use the procedure documented by the package, typically `autoreconf'. configure.ac:6: warning: AC_LANG_CONFTEST: no AC_LANG_SOURCE call detected in body ../../lib/autoconf/lang.m4:193: AC_LANG_CONFTEST is expanded from... ../../lib/autoconf/general.m4:2672: _AC_LINK_IFELSE is expanded from... ../../lib/autoconf/general.m4:2689: AC_LINK_IFELSE is expanded from... aclocal.m4:1037: _LT_SYS_MODULE_PATH_AIX is expanded from... aclocal.m4:4176: _LT_LINKER_SHLIBS is expanded from... aclocal.m4:5251: _LT_LANG_C_CONFIG is expanded from... aclocal.m4:159: _LT_SETUP is expanded from... aclocal.m4:88: LT_INIT is expanded from... configure.ac:6: the top level configure.ac:6: warning: AC_LANG_CONFTEST: no AC_LANG_SOURCE call detected in body ../../lib/autoconf/lang.m4:193: AC_LANG_CONFTEST is expanded from... ../../lib/autoconf/general.m4:2672: _AC_LINK_IFELSE is expanded from... ../../lib/autoconf/general.m4:2689: AC_LINK_IFELSE is expanded from... aclocal.m4:4176: _LT_LINKER_SHLIBS is expanded from... aclocal.m4:5251: _LT_LANG_C_CONFIG is expanded from... aclocal.m4:159: _LT_SETUP is expanded from... aclocal.m4:88: LT_INIT is expanded from... configure.ac:6: the top level configure.ac: warning: missing AC_CHECK_FUNCS([clock_gettime]) wanted by: acs.c:405 configure.ac: warning: missing AC_CHECK_FUNCS([gethrtime]) wanted by: atomicclock.c:52 configure.ac: warning: missing AC_CHECK_FUNCS([gettimeofday]) wanted by: atomicclock.c:99 configure.ac: warning: missing AC_CHECK_HEADERS([mach/mach.h]) wanted by: atomicclock.c:16 configure.ac: warning: missing AC_CHECK_HEADERS([sys/time.h]) wanted by: atomicclock.c:13 configure.ac: warning: missing AC_PROG_CXX wanted by: ltmain.sh:677 configure.ac: warning: missing AC_PROG_RANLIB wanted by: ltmain.sh:1601 configure.ac: warning: missing AC_TYPE_UINT64_T wanted by: acs.c:338 $ 创建您的configure.scan文件,然后您可以剪切-粘贴所需的内容。

configure.scan

完成后,将创建AC_PROG_CPP AC_PROG_INSTALL AC_PROG_LN_S AC_PROG_MAKE_SET AC_PROG_RANLIB # Checks for libraries. # FIXME: Replace `main' with a function in `-lrt': AC_CHECK_LIB([rt], [main]) # Checks for header files. AC_CHECK_HEADERS([mach/mach.h stdint.h stdlib.h string.h sys/time.h unistd.h]) # Checks for typedefs, structures, and compiler characteristics. AC_TYPE_UINT32_T AC_TYPE_UINT64_T # Checks for library functions. AC_CHECK_FUNCS([clock_gettime gethrtime gettimeofday]) AC_CONFIG_FILES([Makefile]) AC_CONFIG_SUBDIRS([automake-1.15]) AC_OUTPUT 文件。我的个人项目的实际示例如下所示:

configure.scan

您可以从configure.am剪切并粘贴所需的内容,并将其插入到您自己的configure.in(或autoscan)文件中的相应部分下。

connection.close()实用程序是autoconf软件包的一部分。