问题标签 [g++-4.7]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
167 浏览

c++ - 带有成员函数的 G++ may_alias

如何获得以下代码以在 g++ 4.7 上编译?如果我放置内联的主体,它将编译foo,但我不希望它内联(因为真正的代码要复杂得多)。

错误:

0 投票
0 回答
777 浏览

c++ - boost::variant< boost::shared_ptr> 不会编译

设置标志时,以下代码无法使用 g++ 4.7.3 编译-std=c++11(错误消息粘贴在底部):

Boost 版本是 1.54。std=c++11它在未设置时编译没有错误,并且还使用 clang 3.4(带或不带-std=c++11)。我很确定这应该是有效的代码,所以这是 g++ 问题还是 boost 问题?如果是这样,究竟是什么错误?

这是错误消息:

0 投票
3 回答
2297 浏览

c++ - 纯虚方法调用——交叉编译

我正在编写一个用于 BeagleBone Black 的基于事件的编程库,但遇到了一个奇怪的错误。

当我用完全相同的标志编译完全相同的代码时,我在基于 ARM 的处理器上收到以下错误,但在我运行为我的 x86 计算机编译的代码时却没有。

当我在笔记本电脑上编译和运行时,程序运行正常

这是我用来编译的命令(ish,我使用的是 Makefile,但两种编译方法都表现出完全相同的行为):

不管我是在实际 BeagleBone 上与 Ubuntu 交叉编译arm-linux-gnueabi-g++还是与 ARM 兼容,我仍然会在 ARM 上遇到错误。g++

我的问题是:什么可能导致此错误,我可以做些什么来尝试找到源?为什么对于相同版本的 G++,这种情况会发生在一种处理器架构上,而不是另一种?

谢谢!

这是来自 ARM 处理器的 GDB 的回溯:

0 投票
3 回答
91 浏览

c++ - 接收容器作为模板参数

我想在某个模板函数中迭代一个容器。如果容器是双端队列但它存储的类型是未知的,我试过:

或者,如果我对未知容器尝试此操作:

两者都给出编译错误。如何在模板函数中创建一个迭代器,以便我可以迭代容器?

0 投票
1 回答
947 浏览

c++ - fork() 输出链

我在 Unix 环境中完全是新手,我在 Robbins 的 Unix 系统编程书中的简单示例中遇到了一些问题。

它是简单的进程链,每个进程都会将一些信息打印到日志文件和 stderr

它使用 g++ 4.7 在 Netbeans 7.1 上编译,运行命令是 "${OUTPUT_PATH}" 10 /home/maxim/testlog.log

所以问题是:

  1. 当我运行或调试项目时,它只会在控制台和文件中打印出 2 或 3 行信息。但是,如果我通过 childpid = fork() 遍历“Step Over”,它会打印有关所有 10 个进程的信息。这是一些编译器优化还是我的错?

  2. 即使它打印所有行,输出看起来像

    某些进程的父pid值为1,这似乎是错误的

0 投票
1 回答
556 浏览

c++ - 正则表达式用模式替换模式

我是正则表达式的新手。我在谷歌上搜索并找到了一些解决方案,然后我想出了自己的解决方案,如下所示

好吧,如果我的字符串包含类似的东西,这段代码就可以正常工作

22-04-2013

它会将其更改为

22/04/2013. 但我希望它是通用的

\d\d-\d\d-\d\d\d\d

替换为

\d\d/\d\d/\d\d\d\d

因为我希望它是通用的。我也在工作linux g++。大多数可用的在线解决方案都在不同的平台上。我还尝试了以下

但没有运气。\d/\d当我进入时我得到了3-4。我不知道为什么。如果我问了一些愚蠢的问题,请原谅我。

编辑

我的问题是匹配一个模式并用一个模式替换它。像数字后跟连字符应替换为数字后跟斜杠。

0 投票
1 回答
2058 浏览

linux - g++ 静态链接到 libstdc++.a 错误

我的应用程序可以通过 CentOS 6.5 附带的 GCC/G++ 4.4.7 成功编译和链接。

我想要静态链接libstdc++.a via -static-libstdc++,但 4.4.7 不支持它。因此我通过以下命令安装了 redhat-devtools-1.1,将 GCC/G++ 升级到 4.7.2

然后用新的工具集编译我的应用程序,它失败了

请问您知道如何解决这个问题吗?

0 投票
1 回答
245 浏览

c++11 - c++11 Makefile 不会编译

我有一个用于上一个程序的简单 Makefile。然而,在这个当前程序中,我使用的是 C++11 功能,并且可以使用 编译我的程序g++47 -std=c++0x test_list.cpp,但是当我在 Makefile 中使用它时,会带来大量错误。

文件:test_list.cpp, List.cpp,List.h

生成文件:

然后我做:make它编译成大量错误。

0 投票
1 回答
8602 浏览

c++ - C++ 程序编译在 Ubuntu 中失败,但在 MacOSX 中有效

嗨,我有一个用 C++ 编写的程序。当我使用 g++ 编译器在 Mac 终端中编译它时,它会编译并运行。但是当我使用 g++ 编译器在 Ubuntu 终端中编译相同的 C++ 程序时,它会失败。我不知道为什么会这样。

Ubuntu 中的 g++ 编译器版本为 4.7.3。

这是我的代码示例

我收到以下错误

seperate.cpp: In function ‘void putbyte(FILE*, unsigned char)’: seperate.cpp:23:21: error: ‘fwrite’ was not declared in this scope seperate.cpp: In function ‘void putshort(FILE*, short unsigned int)’: seperate.cpp:32:21: error: ‘fwrite’ was not declared in this scope seperate.cpp: In function ‘int putlong(FILE*, long unsigned int)’: seperate.cpp:43:28: error: ‘fwrite’ was not declared in this scope seperate.cpp: In function ‘short unsigned int getshort(FILE*)’: seperate.cpp:49:22: error: ‘fread’ was not declared in this scope seperate.cpp: In function ‘long int getlong(FILE*)’: seperate.cpp:56:22: error: ‘fread’ was not declared in this scope seperate.cpp: In function ‘int main(int, char**)’: seperate.cpp:88:11: error: ‘stderr’ was not declared in this scope seperate.cpp:88:69: error: ‘fprintf’ was not declared in this scope seperate.cpp:89:9: error: ‘exit’ was not declared in this scope seperate.cpp:93:30: error: ‘fopen’ was not declared in this scope seperate.cpp:95:11: error: ‘stderr’ was not declared in this scope seperate.cpp:95:61: error: ‘fprintf’ was not declared in this scope seperate.cpp:96:9: error: ‘exit’ was not declared in this scope seperate.cpp:101:22: error: ‘fgetc’ was not declared in this scope seperate.cpp:114:18: error: ‘SEEK_CUR’ was not declared in this scope seperate.cpp:114:26: error: ‘fseek’ was not declared in this scope seperate.cpp:126:38: error: ‘fread’ was not declared in this scope seperate.cpp:131:12: error: ‘fclose’ was not declared in this scope seperate.cpp:138:25: error: ‘fopen’ was not declared in this scope seperate.cpp:141:11: error: ‘stderr’ was not declared in this scope seperate.cpp:141:54: error: ‘fprintf’ was not declared in this scope seperate.cpp:142:9: error: ‘exit’ was not declared in this scope seperate.cpp:153:36: error: ‘fwrite’ was not declared in this scope seperate.cpp:162:11: error: ‘stderr’ was not declared in this scope seperate.cpp:162:54: error: ‘fprintf’ was not declared in this scope seperate.cpp:163:9: error: ‘exit’ was not declared in this scope seperate.cpp:174:36: error: ‘fwrite’ was not declared in this scope seperate.cpp:183:11: error: ‘stderr’ was not declared in this scope seperate.cpp:183:54: error: ‘fprintf’ was not declared in this scope seperate.cpp:184:9: error: ‘exit’ was not declared in this scope seperate.cpp:195:36: error: ‘fwrite’ was not declared in this scope dfo@ubuntu:~/Desktop/abc-master$ g++ -v

0 投票
2 回答
401 浏览

c++ - 将字符数组转换为结构时出现段错误

当我使用 g++ 4.7 编译并运行时,我试图将一个 char 数组转换为一个结构并接收一个段错误,但当我使用 clang 3.3 编译并运行程序时却没有。

这是消息结构描述:

这是导致段错误的行:

数据包对象属于以下类型:

这是 gdb 生成的回溯:

我不确定为什么当我使用 g++ 而不是使用 clang 编译时这是段错误?

编辑:这就是 SendMessage() 的样子: