我已经使用这些标志从svn构建了一个最新的vanilla GCC :
../configure \
--enable-languages=c,c++ \
--disable-nls \
--enable-multilib \
--prefix=/opt/other/gcc-svn \
--program-suffix=-svn \
--with-system-zlib
Run Code Online (Sandbox Code Playgroud)
首先用clang 3.4,然后我认为它可以铛的错(与一粒盐)和重建GCC一次
多用GCC 4.8.1,这导致了完全相同的结果.
当我尝试使用大约编译C++项目时,生成的GCC 比GCC 4.8.1慢大约17秒.150k行代码.
这些是我得到的构建时间(-O3):
g++ 4.9:48秒 g++ 4.8:31秒 clang 3.4:13秒我错过了configure一面旗帜还是GCC 4.9真的那么慢?!
对不起,标题可能有点刺激,但我不知道更好.无论如何,我想要一个bash脚本可以在FreeBSD,OpenBSD和Linux上运行而无需修改它,但是bash并不位于Linux和BSD的同一个地方.
所以,如果我写,#!/bin/bash那么它将不适用于BSD,因为bash shell位于/usr/local/bin/bash那里.是否有任何解决方案可以让这个脚本同时工作?
或者我真的需要发送两个不同路径的脚本......?
请考虑以下代码:
class A {
private:
int a;
public:
A(int a) : a(a) { }
};
class B : public A {
private:
int b;
bool init() {
b = 0;
return true;
}
public:
// init() is a hack to initialize b before A()
// B() : b(0), A(b) {} yields -Wreorder
// B() : A((b = 0)) {} no warning (but this one doesn't work so well with non-pod (pointer) types)
B() : A(init() ? b : 0) {} …Run Code Online (Sandbox Code Playgroud) #include <stdio.h>
// xyz will be emitted with -flto (or if it is static) even when
// the function is unused
__attribute__((__used__))
void xyz() {
printf("Hello World!\n");
}
int main() {
return 0;
}
Run Code Online (Sandbox Code Playgroud)
我需要什么呢?
xyz除了直接调用函数之外,还有什么方法可以达到某种程度,比如dlsym()像魔法一样?
我正在尝试编写一个返回父进程名称的函数,
如果是bash,那么它应该返回bash.
const std::string &getParentProcessName() {
static std::string name;
auto ppid = getppid();
#ifdef __FreeBSD__
// ?????
#else
...
#endif
name = "unknown";
return name;
}
Run Code Online (Sandbox Code Playgroud)