使用 automake 设置每个文件标志
有没有办法使用 automake 在每个文件的基础上设置标志?
特别是,如果我有一个 C++ 项目,并且想要使用 -W 编译除我想要禁用特定警告的文件之外的所有文件,我该怎么办?
我尝试过类似的方法:
CXXFLAGS = -WAll ...
bin_PROGRAMS = test
test_SOURCES = main.cpp utility.cpp
utility_o_CXXFLAGS = $(CXXFLAGS) -Wno-unused-value
但没有成功。
编辑:删除了对 automake 手册的引用,这实际上是误导性的(感谢 Douglas Leeder)。
Is there a way set flags on a per-file basis with automake?
In particular, if I have a c++ project and want to compile with -WAll all the files except one for which I want to disable a particular warning, what could I do?
I tried something like:
CXXFLAGS = -WAll ...
bin_PROGRAMS = test
test_SOURCES = main.cpp utility.cpp
utility_o_CXXFLAGS = $(CXXFLAGS) -Wno-unused-value
but it didn't work.
EDITED: removed reference to automake manual, which was actually misleading (thanks to Douglas Leeder).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您无法使用
automake
执行此操作...但使用make
可以执行 =) 将以下行添加到您的Makefile.am
:参见 GNU Make 文档:目标特定变量值了解详细信息。
You can't do this with
automake
... but can do withmake
=) Add following line to yourMakefile.am
:See GNU Make documentation : Target-specific Variable Values for details.
Automake 仅支持每个目标标志,而您需要每个对象标志。 一种解决方法是创建一个包含您的对象的小型库:
Automake only supports per-target flags, while you want per-object flags. One way around is to create a small library that contains your object:
你很困惑 - 该部分指的是 automake 本身的选项。
这是设置 automake 命令行选项的一种方法:
第 17 节中列出的每个文件是指每个 Makefile,而不是源文件。
我不知道任何每个源文件标志设置,但您可以使用以下方法为每个结果二进制文件设置选项:
You've got confused - that section is referring to options to automake itself.
It's a way of setting the automake command-line options:
The per-file listed in section 17 refers to per-Makefile not source file.
I'm not aware of any per-source file flag setting, but you can set the option for each result binary with:
要禁用特定编译单元中的特定警告,您可以使用
#pragma GCC Diagnosticigned -W...
,如 GCC 文档。To disable a particular warning in a specific compilation unit, you can use
#pragma GCC diagnostic ignored -W...
, as described in the GCC documentation.