g++

Compiling C++ code makes the system hang

我的未来我决定 提交于 2019-12-29 07:51:30
问题 When I try to compile this file by issuing the command, "g++ qr.cpp -o qr" The system hangs. I haven't seen this kind of an error anywhere else. #include<iostream> using namespace std; bool win[1000000001]; bool know[1000000001]; int sixes[] = {6, 36, 216, 1296, 7776, 46656, 279936, 1679616, 10077696, 60466176, 362797056}; bool check(int n){ cout << n << endl; if(!know[n]){ bool b = check(n-1); for(int i=0; i<11; i++){ if(n > sixes[i]){ b = b & check(n-sixes[i]); } } win[n] = !b; } return win

Wrapper for `__m256` Producing Segmentation Fault with Constructor - Windows 64 + MinGW + AVX Issues

天大地大妈咪最大 提交于 2019-12-29 07:42:22
问题 I have a union that looks like this union bareVec8f { __m256 m256; //avx 8x float vector float floats[8]; int ints[8]; inline bareVec8f(){ } inline bareVec8f(__m256 vec){ this->m256 = vec; } inline bareVec8f &operator=(__m256 m256) { this->m256 = m256; return *this; } inline operator __m256 &() { return m256; } } the __m256 needs to be aligned on 32 byte boundary to be used with SSE functions, and should be automatically, even within the union. And when I do this bareVec8f test = _mm256_set1

Compilation problems with vector<auto_ptr<> >

你说的曾经没有我的故事 提交于 2019-12-29 07:40:07
问题 Consider the following code: #include <iostream> #include <memory> #include <vector> using namespace std; struct A { int a; A(int a_):a(a_) {} }; int main() { vector<auto_ptr<A> > as; for (int i = 0; i < 10; i++) { auto_ptr<A> a(new A(i)); as.push_back(a); } for (vector<auto_ptr<A> >::iterator it = as.begin(); it != as.end(); ++it) cout << (*it)->a << endl; } When trying to compile it, I get the following obscure compiler error from g++: g++ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF

What is g++'s -pthread equiv in clang?

青春壹個敷衍的年華 提交于 2019-12-29 07:25:08
问题 I'm switching over from g++ to clang however, in g++, I have the -pthread flag, which clang does not seem to recognize. What is the equiv in clang? EDIT: My clang build is pulling from svn on March 5 2010. 回答1: Clang supports -pthread . May be in the latest builds, so update it and try again. 回答2: clang requires -pthread when compiling but not when linking. This is annoying, but it is observed behavior: $ clang -c x.cpp $ clang -pthread -c x.cpp $ clang -o x x.o $ clang -pthread -o x x.o

Print layout of C++ object with g++ compiler

风流意气都作罢 提交于 2019-12-29 06:45:32
问题 Is there a way to print the layout of a C++ object using the g++ compiler or any other means. A simplified example (assuming int takes 4 bytes) class A{ int a; }; class B:public A{ int b; } so the output would be A- 0 4 + a + B- 0 4 8 + A.a + b + It would be useful to understand the layout of objects (in my case virtual machine code). Thanks in advance. Regards, Zaheer 回答1: Looking at the man pages, -fdump-class-hierarchy maybe? 回答2: The information you seek is needed by debuggers and is

What header file needs to be included for using nullptr in g++?

早过忘川 提交于 2019-12-29 06:39:08
问题 I am using g++ 4.4.1 and want to use nullptr , but I am not being able to find which header file is required to be included. It does not seem to be keyword either, because my attempt to use it is rejected as error: 'nullptr' was not declared in this scope 回答1: GCC 4.4.1 does not support nullptr . Support for nullptr was added in GCC 4.6.0: http://gcc.gnu.org/gcc-4.6/changes.html Improved experimental support for the upcoming C++0x ISO C++ standard, including support for nullptr (thanks to

GNU C++ error messages [closed]

六月ゝ 毕业季﹏ 提交于 2019-12-29 06:22:40
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed last year . Is there a comprehensive list of error/warning messages for the g++ compiler available online? I'm looking for something similar to the MSDN documentation which describes what each message means and possibly has some sample code which demonstrates the conditions which would cause such an error. I've looked at the

C++ std::shared_ptr usage and information

﹥>﹥吖頭↗ 提交于 2019-12-29 04:36:32
问题 I am trying to use std::shared_ptr in my code. I have seen there have been other questions on the subject, but I am still getting a compiler error. Have I got the right version of gcc and setup? What I have done: I have tried to compile my code with both headers separately — <memory> and <tr1/memory> but still get the errors below in both cases. The version of gcc I am using is gcc --version gcc (GCC) 4.3.2 When I include <memory> header I use std::shared_ptr and with the <tr1/memory> header

C++ std::shared_ptr usage and information

耗尽温柔 提交于 2019-12-29 04:36:28
问题 I am trying to use std::shared_ptr in my code. I have seen there have been other questions on the subject, but I am still getting a compiler error. Have I got the right version of gcc and setup? What I have done: I have tried to compile my code with both headers separately — <memory> and <tr1/memory> but still get the errors below in both cases. The version of gcc I am using is gcc --version gcc (GCC) 4.3.2 When I include <memory> header I use std::shared_ptr and with the <tr1/memory> header

g++ doesn't compile constexpr function with assert in it

狂风中的少年 提交于 2019-12-29 04:25:44
问题 template<typename T> constexpr inline T getClamped(const T& mValue, const T& mMin, const T& mMax) { assert(mMin < mMax); // remove this line to successfully compile return mValue < mMin ? mMin : (mValue > mMax ? mMax : mValue); } error : body of constexpr function 'constexpr T getClamped(const T&, const T&, const T&) [with T = long unsigned int]' not a return-statement Using g++ 4.8.1 . clang++ 3.4 doesn't complain. Who is right here? Any way I can make g++ compile the code without using