链接期间我有以下警告:
/usr/bin/ld: warning: libxxx.so.6, needed by /a/b/c/libyyy.so, not found (try using -rpath or -rpath-link)
Run Code Online (Sandbox Code Playgroud)
设置环境变量LD_LIBRARY_PATH = path_to_libxxx.so.6使警告静音(添加-Lpath_to_libxxx.so.6没有帮助).
我有一个单独的编译服务器,其中生成的二进制文件只是编译.二进制文件在其他服务器上执行,二进制文件可以看到libxxx.so.6(选中ldd executable).
是否还有其他方法可以在编译时摆脱警告(我有几次并且非常烦人)?
我想比较Google协议缓冲区的两个消息或(两个子参数).我没有找到实现它的API.
有任何想法吗?
我set -e前段时间遇到过,我承认我喜欢它.现在,经过一段时间我回来写一些bash脚本.
我的问题是,是否有一些最佳实践何时使用set -e以及何时不使用它(例如小型/大型脚本等)或者我应该使用类似cmd || exit 1跟踪错误的模式?
试图结合ccache和colorgcc.以下链接文字:
运行g ++ --version时接收:
Can't exec "ccache /usr/bin/gcc": No such file or directory at /usr/lib/perl5/5.8.8/IPC/Open3.pm line 246.
open3: exec of ccache /usr/bin/gcc --version failed at /usr/local/bin/colorgcc/gcc line 208
Run Code Online (Sandbox Code Playgroud)
任何想法如何解决?
我在代码中多次遇到std :: vector类型为std :: vector的类成员的std :: vector :: clear()在构造函数和析构函数中调用.
我不明白为什么需要它:
我错过了什么吗?
我希望在示例中,bellow编译器将无法编译代码,因为它不知道什么是"find()",它在算法头中的std命名空间中定义.
但是,此代码使用gcc 4.1.2在RHEL 5.3上编译.
我错过了什么?
#include <string>
#include <algorithm>
int main()
{
std::string s;
find(s.begin(), s.end(), 'a'); // should not compile
}
Run Code Online (Sandbox Code Playgroud) 在以下示例中:
class A
{
public:
int len();
void setLen(int len) { len_ = len; } // warning at this line
private:
int len_;
};
Run Code Online (Sandbox Code Playgroud)
gcc with -Wshadow发出警告:
main.cpp:4: warning: declaration of `len' shadows a member of `this'
Run Code Online (Sandbox Code Playgroud)
函数len和整数len是不同类型的.为什么警告?
更新
我看到"阴影"的含义是广泛的.从形式上看,编译器也完全符合它的含义.
不过恕我直言,这面旗帜并不实用.例如常用的setter/getter成语:
class A {
void prop(int prop); // setter
int prop() const; // getter
int prop;
};
Run Code Online (Sandbox Code Playgroud)
如果有一个警告标志不会在这种情况下发出警告会很好,但会在"int a"隐藏"int a"的情况下发出警告.
添加-Wshadow对我的遗留代码发出大量警告,同时我不时发现由"阴影"问题引起的错误.
我不介意它会被称为"-Wmuch_more_practical_and_interesting_shadow"或"-Wfoooooo".
那么,是否有其他 gcc警告标志符合我的描述?
更新2
不仅我认为-Wshadow不知何故没有用的链接文本.我并不孤单:)不太严格的检查可能会更有用.
UTS_RELEASE在Linux中定义内核版本.它的定义generated/utsrelease.h是由主Makefile创建的,如下所示:
# KERNELRELEASE can change from a few different places, meaning version.h
# needs to be updated, so this check is forced on all builds
uts_len := 64
define filechk_utsrelease.h
if [ `echo -n "$(KERNELRELEASE)" | wc -c ` -gt $(uts_len) ]; then \
echo '"$(KERNELRELEASE)" exceeds $(uts_len) characters' >&2; \
exit 1; \
fi; \
(echo \#define UTS_RELEASE \"$(KERNELRELEASE)\";)
endef
Run Code Online (Sandbox Code Playgroud)
我想知道UTS代表什么,这里?
c++ ×5
gcc ×3
linux ×3
compilation ×2
stl ×2
bash ×1
ccache ×1
dynamic-cast ×1
linux-kernel ×1
namespaces ×1
networking ×1
rtti ×1
shell ×1
tcp ×1