我一直在查看Boost库的源代码,我注意到通常只有单个符号没有附加任何预处理器指令.我阅读了GCC预处理器手册和规范指南,但没有找到任何相关信息.
(1) #ifndef BOOST_CONFIG_HPP
(2) # include <boost/config.hpp>
(3) #endif
(4) #
(5) #if defined(BOOST_HAS_PRAGMA_ONCE)
(6) # pragma once
(7) #endif
Run Code Online (Sandbox Code Playgroud)
在第4行,英镑符号后没有任何内容.这有什么影响?它是在C预处理器(CPP)规范中定义的吗?
由于Boost是一个跨平台的库,我认为任何CPP都应该正确解析它.在整个代码中使用随机井号/井号的影响/副作用是什么?
GNU Make中CPPFLAGS和CXXFLAGS之间有什么区别?
我通常使用选项:-Dname = value将宏定义从"make命令行"传递给"makefile".该定义可在makefile中访问.
我还使用类似的编译器选项将宏定义从"makefile"传递到"源代码":-Dname = value(在许多编译器中都支持).可以在源代码中访问此定义.
我现在需要的是允许我的makefile用户能够立即将"make.exe命令行"中的任意宏定义传递给"源代码",而无需更改makefile中的任何内容.
所以用户可以输入:make -f mymakefile.mk -SOMEOPTION var = 5
然后直接代码main.c可以看到var:
int main()
{
int i = var;
}
Run Code Online (Sandbox Code Playgroud) 我正在使用GNU make来编译我的C++代码,我想了解如何使我的编译可以自定义.
我在不同的地方阅读CFLAGS,CCFLAGS并CXXFLAGS用于此目的.那我该怎么用呢?如果我有额外的命令行参数编译器,我应该将它们附加CFLAGS或前置它们吗?有共同的做法吗?
为什么三个不同的变量?我想C编译器应该得到CFLAGS和CCFLAGS,而C++编译器应该得到CFLAGS和CXXFLAGS-我有没有得到它吗?
人类用户是否应该设置这些变量?做任何自动化工具(automake,autoconf,等)设置它们?我应该使用的linux系统没有定义任何这些变量 - 这是典型的吗?
目前我的Makefile看起来像这样,我觉得它有点脏:
ifdef code_coverage
GCOV_FLAG := -fprofile-arcs -ftest-coverage
else
GCOV_FLAG :=
endif
WFLAGS := -Wall
INC_FLAGS := -Istuff -Imore_stuff -Ietc
CCFLAGSINT := -O3 $(WFLAGS) $(INC_FLAGS) $(CCFLAGS)
... (somewhere in the makefile, the command-line for compilation looks like this)
$(CC) $(CCFLAGSINT) -c $< -o $@
... (somewhere in the makefile, the command-line for linking looks …Run Code Online (Sandbox Code Playgroud) 在使用Makefile创建项目时,我收到此错误:
error: implicit declaration of function ‘fatal’ [-Werror=implicit-function-declaration]
cc1: all warnings being treated as errors
Run Code Online (Sandbox Code Playgroud)
./configure --help显示
Optional Features:
--disable-option-checking ignore unrecognized --enable/--with options
--disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
--enable-FEATURE[=ARG] include FEATURE [ARG=yes]
--disable-dependency-tracking speeds up one-time build
--enable-dependency-tracking do not reject slow dependency extractors
--disable-gtktest do not try to compile and run a test GTK+ program
--enable-debug Turn on debugging
Run Code Online (Sandbox Code Playgroud)
怎么能告诉configure不要包含-Werror?
CXX中cmake CMakeLists.txt文件中的"XX"是什么.
它的意义是什么.
为什么CPX文件中的"XX"不是PP?
./configure --enable-avfilter --enable-filter=movie --enable-gpl --enable-postproc \
--enable-swscale --enable-avfilter --enable-libmp3lame --enable-libvorbis \
--enable-libtheora --enable-libdirac --enable-libschroedinger --enable-libfaac \
--enable-libxvid --enable-libx264 --enable-libvpx --enable-libspeex --enable-nonfree \
--enable-shared --enable-pthreads --disable-indevs --cc=/usr/bin/gcc-4.2 --arch=x86_64
Run Code Online (Sandbox Code Playgroud)
给出错误:
错误:未找到libfaac
如果您认为configure出错,请确保您使用的是SVN的最新版本.如果最新版本失败,请将问题报告给irc.freenode.net上的ffmpeg-user@mplayerhq.hu邮件列表或IRC#ffmpeg.包括configure生成的日志文件"config.log",因为这将有助于解决问题.
但是locate faac给了
/opt/local/bin/faac
/opt/local/include/faac.h
/opt/local/include/faaccfg.h
/opt/local/lib/libfaac.0.dylib
/opt/local/lib/libfaac.a
/opt/local/lib/libfaac.dylib
Run Code Online (Sandbox Code Playgroud)
知道我怎么能告诉配置脚本如何找到libfaac?
我已经阅读了CFLAGS 和 CPPFLAGS之间的区别。但是我的 Makefile.am 目前同时使用 DEFS 和 CPPFLAGS,我不确定其中的区别。
DEFS += -DLOCALEDIR=\"$(localedir)\" -DDATADIR=\"$(datadir)\" -DPKGDATADIR=\"$(pkgdatadir)\"
Run Code Online (Sandbox Code Playgroud)
和:
src_foo_CPPFLAGS = \
$(AM_CPPFLAGS) \
-I$(top_builddir)/src \
-DDATADIR='"$(datadir)"' \
-DMODULEDIR='"$(moduledir)"' \
-DLIBEXECDIR='"$(libexecdir)"'
Run Code Online (Sandbox Code Playgroud)
CPPFLAGS 和 DEFS 似乎都使用该选项创建定义-D。那么有什么区别。我可以删除DEFS并添加缺少的定义(PKGDATADIR和LOCALEDIR)CPPFLAGS吗?