如何阻止 automake 添加 -I.到我的编译行?

发布于 2024-08-10 02:15:07 字数 444 浏览 3 评论 0原文

如何阻止 automake 添加 -I.到我的编译行?

似乎 automake 或 libtool 对象总是有一个类似于以下内容的编译命令:

g++ -DHAVE_CONFIG_H -I. -I./proj/otherdir -o myprog.o myprog.c

问题是我有两个同名的头文件....

./proj/otherdir/Header.h
./proj/thisdir/Header.h

每个头都有一个名为 Header 的类,尽管每个头都位于不同的命名空间中。因此,当我在 ./proj/thisdir 中构建时,“-I”。被包含在内,我无法到达 ./proj/otherdir 中的标题,

我不知道如何摆脱最初的“-I”。出现。

有什么提示吗?

谢谢 陈兹

How do I stop automake from adding -I. to my compile line?

It seems automake or libtool objects always have a compile command similar to:

g++ -DHAVE_CONFIG_H -I. -I./proj/otherdir -o myprog.o myprog.c

The problem is that I have two header files with the same name....

./proj/otherdir/Header.h
./proj/thisdir/Header.h

Each header has a class named Header, although each is in a different namespace. So when I am building in ./proj/thisdir, the "-I." gets included and I can't get to the header in ./proj/otherdir

I don't know how to get rid of that initial "-I." that appears.

Any hints?

Thanks
Chenz

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

孤单情人 2024-08-17 02:15:07

您所要做的就是在 Makefile.am 中设置

DEFAULT_INCLUDES =

,然后一切就都很好了。

陈兹

all you have to do is set in the Makefile.am

DEFAULT_INCLUDES =

and then all is good in the world.

Chenz

感悟人生的甜 2024-08-17 02:15:07

如果我编写时您的 API 包含不同的标头,

#include <Header.h>

那么该 API 就会变得混乱且容易出错。

为什么不像

#include <thisdir/Header.h>

and

#include <otherdir/Header.h>

那样定义您的 API然后,如果需要,您甚至可以引用同一源文件中的两个标头。只需阅读 include 行,您就会知道它实际包含的内容。

If your API includes different headers when I write

#include <Header.h>

that makes that API confusing and error prone.

Why not define your API like

#include <thisdir/Header.h>

and

#include <otherdir/Header.h>

Then you could even refer to both headers in the same source file if required. And you would know just from reading the include line what it actually includes.

没有你我更好 2024-08-17 02:15:07

查看您的应用程序的configure.ac或configure.in,应该在那里

Look in the configure.ac or configure.in for your app, should be in there

别低头,皇冠会掉 2024-08-17 02:15:07

它不会删除 -I.,但您可以将相对路径放入 #include 指令中:

#include "../otherdir/Header.h"
#include "../thisdir/Header.h"

It doesn't get rid of -I., but you can put relative paths in your #include directives:

#include "../otherdir/Header.h"
#include "../thisdir/Header.h"
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文