g++

g++: error: CreateProcess no such file or directory

扶醉桌前 提交于 2020-01-15 04:05:58
问题 I get the following error: g++: error: CreateProcess no such file or directory whenever I try to compile a program. I have installed the MinGw 7.2 version at work on a windows machine and the problem does not occur, however after installing Windows SP3 on my home computer I get this error and I just can't figure it out since I have set all the environment variables properly. I even tried setting the path to C:\MinGw\libexec\gcc\i686-mingw32\4.6.1 where cc1plus.exe and cc1.exe are located but

Placement new on non-pointer variables and class members

不羁岁月 提交于 2020-01-14 16:49:02
问题 Consider the following example: #include <iostream> struct A { int i; A(int i) { this->i = i; } A &operator=(const A &a) = delete; A(const A &a) = delete; }; int main() { A a(1); new(&a) A(5); //a = A(7); // not allowed since = is deleted in A std::cout << a.i << std::endl; } This is a simple example using the placement new operator. Since the copy constructor and assignment operator of struct A have been deleted (for whatever reason), it is not possible to change the object the variable A a

Placement new on non-pointer variables and class members

久未见 提交于 2020-01-14 16:46:31
问题 Consider the following example: #include <iostream> struct A { int i; A(int i) { this->i = i; } A &operator=(const A &a) = delete; A(const A &a) = delete; }; int main() { A a(1); new(&a) A(5); //a = A(7); // not allowed since = is deleted in A std::cout << a.i << std::endl; } This is a simple example using the placement new operator. Since the copy constructor and assignment operator of struct A have been deleted (for whatever reason), it is not possible to change the object the variable A a

Conversion to `const Y` not applicable for `R&&` on clang

大城市里の小女人 提交于 2020-01-14 09:43:10
问题 The following code compiles fine with g++ (GCC) 4.7.1 20120721 , but fails with a recently build clang version 3.2 (trunk) . struct Y {}; struct X { operator const Y() const { return Y(); } }; void f(Y&& y) {} int main() { f(X()); return 0; } Changing the conversion operator to operator Y() const is sufficient to make the code compile on both compilers. Which compiler is actually standard compliant in this case? What does the standard actually say about this? The verbatim error as requested:

C++: Core dump with packaged_task

ε祈祈猫儿з 提交于 2020-01-14 09:32:50
问题 I got a strange core dump which I copied from a part of code in http://en.cppreference.com/w/cpp/thread/packaged_task, #include <future> #include <iostream> #include <cmath> void task_lambda() { std::packaged_task<int(int,int)> task([](int a, int b) { return std::pow(a, b); }); std::future<int> result = task.get_future(); task(2, 9); std::cout << "task_lambda:\t" << result.get() << '\n'; } int main() { task_lambda(); } I got this terminate called after throwing an instance of 'std::system

Simple program crashes

自古美人都是妖i 提交于 2020-01-14 07:14:46
问题 So I've been using MinGW GCC version 4.4 or a while, and decided it's time to upgrade. I went to the MinGW website and downloaded the latest version of GCC (4.7.0). After deleting my previous version, and installing the newest version, even the simplest program will crash. For example, if I compile this program #include <iostream> using namespace std; int main () { cout << "Hello, World" << endl; return 0; } with the command line g++ hello.cpp -o hello.exe It will print out "Hello, World" and

Simple program crashes

两盒软妹~` 提交于 2020-01-14 07:14:34
问题 So I've been using MinGW GCC version 4.4 or a while, and decided it's time to upgrade. I went to the MinGW website and downloaded the latest version of GCC (4.7.0). After deleting my previous version, and installing the newest version, even the simplest program will crash. For example, if I compile this program #include <iostream> using namespace std; int main () { cout << "Hello, World" << endl; return 0; } with the command line g++ hello.cpp -o hello.exe It will print out "Hello, World" and

Why does g++ store class names in the compiled binary?

痴心易碎 提交于 2020-01-14 07:12:14
问题 I noticed that If I run strings on my program which was compiled by g++ the output contains the names of various classes that it uses. The program was compiled with -O3 and without -g or -p , and the class names are still present when I strip the binary. I was wondering why it is necessary for g++ to store this information in the binary? The class names that are present all seem to be classes that use virtual functions, so I suspect this is something to do with it. 回答1: This might have

std::stoi not recognized by eclipse

核能气质少年 提交于 2020-01-13 19:50:59
问题 On my system, running Windows 7 x64, Eclipse Luna, and g++ 4.9.2 (installed via cygwin), it seems std::stoi was never declared by g++. According to the documentation, stoi is part of the string library, so obviously I have #include <string> . In addition, I know that stoi was introduced in C++11, and I have set the appropriate flags for my compiler (g++), even though this seems like an IDE error , rather than a compiler error. Still, I would get one of the following error messages when

std::stoi not recognized by eclipse

两盒软妹~` 提交于 2020-01-13 19:50:12
问题 On my system, running Windows 7 x64, Eclipse Luna, and g++ 4.9.2 (installed via cygwin), it seems std::stoi was never declared by g++. According to the documentation, stoi is part of the string library, so obviously I have #include <string> . In addition, I know that stoi was introduced in C++11, and I have set the appropriate flags for my compiler (g++), even though this seems like an IDE error , rather than a compiler error. Still, I would get one of the following error messages when