English 中文(简体)
利用汽车时的冲突
原标题:Conflicting PACKAGE_NAME and other macros when using autotools

在利用图书馆的自动工具(有config.h文档)和该图书馆的软件时,汇编者抱怨对一些宏观产品进行了重新定义(PACKAGE_NAME,PACKAGE_TARNAME等)。

我如何防止这种情况?

图书馆需要<代码>config.h文档,以将其安装到使用该软件的软件上。

现在,我有一份包装稿library_config.h,其中包括原来的config.h,并规定了用户不使用自动工具,但甚至未确定该一揽子计划中的宏观标准时的违约情况。

#ifndef LIB_CONFIG_H
#define LIB_CONFIG_H
#ifdef HAVE_CONFIG_H
#  include "config.h"
#  undef PACKAGE
#  undef PACKAGE_BUGREPORT
#  undef PACKAGE_NAME
#  undef PACKAGE_STRING
#  undef PACKAGE_TARNAME
#  undef PACKAGE_VERSION
#  undef VERSION
#else
#  if defined (WIN32)
#    define HAVE_UNORDERED_MAP 1
#    define TR1_MIXED_NAMESPACE 1
#  elif defined (__GXX_EXPERIMENTAL_CXX0X__)
#    define HAVE_UNORDERED_MAP 1
#  else
#    define HAVE_TR1_UNORDERED_MAP 1
#  endif
#endif
#endif

我认为,最好选择是在没有图书馆的情况下: 我如何避免在图书馆使用汽车时对PACKAGE、PACKAGE_NAME等的定义?

EDIT:正好解释。

使用<代码> AC_CONFIG_HEADER XI in the configure.ac of the Library I produced a config.h file with a Much ofeu definitions. 这一定义对图书馆本身(其编集部分和标题档案)和客户软件都有用。 但这正是<代码>。 AC_CONFIG_HEADER将我需要的有用宏观与固定名称的其他通用定义(PACKAGE,PACKAGE_NAME)混为一谈,即当汽车也用于客户软件配置时,这些术语会发生冲突。

最佳回答

如果你的申请可能与图书馆有动态联系,那么将图书馆的静态插座固定在申请中就毫无意义。

否则,您可能希望查阅ax_prefix_config_h.m4

我仍在试图避免安装<代码>config.h文档,并在不使用<代码>config.h的情况下界定图书馆的节目。

/* library.h */
const char library_version[];

/* library.c */
#include "library.h"
#include "config.h" /* the library s config.h */
const char library_version[] = PACKAGE_VERSION;

/* application.c */
#include "library.h"
#include "config.h" /* the application s config.h */
int main()
{
   print("This is app version %s.
", PACKAGE_VERSION);
   print("The library is version %s
", library_version);
   return 0;
}

确保公共图书馆负责人的档案不#include “config.h”,并确保图书馆不安装config.h

问题回答

您应能够将图书馆指定为软件的“子包”,在软件<代码>configure.ac上打电话<>AC_CONFIG_SUBDIRS([图书馆])。 这应当消除冲突,从高层会议到次分组会议的环境仍将传播。

这里是介绍这一特征的《自治手册》网页链接:。 http://www.gnu.org/software/hello/manual/automake/Sub Pack.html





相关问题
gcc -fPIC seems to muck with optimization flags

Following along from this question: how-do-i-check-if-gcc-is-performing-tail-recursion-optimization, I noticed that using gcc with -fPIC seems to destroy this optimization. I am creating a shared ...

Generate assembler code from C file in linux

I would like to know how to generate assembler code from a C program using Unix. I tried the gcc: gcc -c file.c I also used firstly cpp and then try as but I m getting errors. I m trying to build an ...

Getting rid of pre-compiled headers

OK, I have old Metrowerks code for Mac and Windows where the previous developer used pre-compiled headers for every project that this code base builds. How does one get rid of Pre-compiled headers, ...

Include a .txt file in a .h in C++?

I have a number of places where I need to re-use some template code. Many classes need these items In a .h could I do something like: #include <xxx.txt> and place all of this code in the ....

How to compile for Mac OS X 10.5

I d like to compile my application for version 10.5 and forward. Ever since I upgraded to Snow Leopard and installed the latest XCode, gcc defaults to 10.6. I ve tried -isysroot /Developer/SDKs/...

热门标签