g++

How does #include <bits/stdc++.h> work in C++? [duplicate]

别等时光非礼了梦想. 提交于 2019-12-17 02:04:26
问题 This question already has answers here : Why should I not #include <bits/stdc++.h>? (4 answers) Closed last year . I have read from a codeforces blog that if we add #include <bits/stdc++.h> in a C++ program then there is no need to include any other header files. How does #include <bits/stdc++.h> work and is it ok to use it instead of including individual header files? 回答1: It is basically a header file that also includes every standard library and STL include file. The only purpose I can see

Compiling C++11 with g++

我怕爱的太早我们不能终老 提交于 2019-12-16 20:33:32
问题 I'm trying to update my C++ compiler to C++11. I have searched a bit and I have come to the conclusion that I have to use the flag -std=c++0x or -std=gnu++0x , but I don't know many things about flags. Can anyone help me? (I'm using Ubuntu 12.04.) Here is the error that I get from the compiler when I attempt to use a library which is included in C++11 (i.e. array): #include <array> #include <iostream> int main() { std::array<int, 3> arr = {2, 3, 5}; ... } This file requires compiler and

Compiling C++11 with g++

北慕城南 提交于 2019-12-16 20:33:30
问题 I'm trying to update my C++ compiler to C++11. I have searched a bit and I have come to the conclusion that I have to use the flag -std=c++0x or -std=gnu++0x , but I don't know many things about flags. Can anyone help me? (I'm using Ubuntu 12.04.) Here is the error that I get from the compiler when I attempt to use a library which is included in C++11 (i.e. array): #include <array> #include <iostream> int main() { std::array<int, 3> arr = {2, 3, 5}; ... } This file requires compiler and

Compiling C++11 with g++

假如想象 提交于 2019-12-16 20:33:11
问题 I'm trying to update my C++ compiler to C++11. I have searched a bit and I have come to the conclusion that I have to use the flag -std=c++0x or -std=gnu++0x , but I don't know many things about flags. Can anyone help me? (I'm using Ubuntu 12.04.) Here is the error that I get from the compiler when I attempt to use a library which is included in C++11 (i.e. array): #include <array> #include <iostream> int main() { std::array<int, 3> arr = {2, 3, 5}; ... } This file requires compiler and

Compiling C++11 with g++

大兔子大兔子 提交于 2019-12-16 20:33:01
问题 I'm trying to update my C++ compiler to C++11. I have searched a bit and I have come to the conclusion that I have to use the flag -std=c++0x or -std=gnu++0x , but I don't know many things about flags. Can anyone help me? (I'm using Ubuntu 12.04.) Here is the error that I get from the compiler when I attempt to use a library which is included in C++11 (i.e. array): #include <array> #include <iostream> int main() { std::array<int, 3> arr = {2, 3, 5}; ... } This file requires compiler and

Undefined reference to vtable

萝らか妹 提交于 2019-12-14 04:20:41
问题 When building my C++ program, I'm getting the error message undefined reference to 'vtable... What is the cause of this problem? How do I fix it? It so happens that I'm getting the error for the following code (The class in question is CGameModule.) and I cannot for the life of me understand what the problem is. At first, I thought it was related to forgetting to give a virtual function a body, but as far as I understand, everything is all here. The inheritance chain is a little long, but

Linking LAPACK library with g++ on cygwin

北战南征 提交于 2019-12-14 03:54:49
问题 Background I am trying to find the eigenvalues of a complex matrix by using zgeev routine in LAPACK library. As far as I understand, LAPACK is written for FORTRAN and hence to use it with a C (or C++) program one has to make several modifications such as transforming the matrix and appending an underscore in the routine-name (REFERENCE:http://www.physics.orst.edu/~rubin/nacphy/lapack/codes/eigen-c.html) Problem To link LAPACK library to a C++ program (http://www.physics.orst.edu/~rubin/nacphy

Functions only getting inlined if defined in a header. Am I missing something?

谁都会走 提交于 2019-12-14 03:52:19
问题 Using gcc v4.8.1 If I do: //func.hpp #ifndef FUNC_HPP #define FUNC_HPP int func(int); #endif //func.cpp #include "func.hpp" int func(int x){ return 5*x+7; } //main.cpp #include <iostream> #include "func.hpp" using std::cout; using std::endl; int main(){ cout<<func(5)<<endl; return 0; } Even the simple function func will not get inlined. No combination of inline , extern , static , and __attribute__((always_inline)) on the prototype and/or the definition changes this (obviously some

NOT sharing all classes with shared library

帅比萌擦擦* 提交于 2019-12-14 03:39:50
问题 As ugly as win32 Microsoft compiler is by using the __declspec macro, it does have the advantage of being explicit about what you want to export or not. Moving the same code onto a Linux gnu/gcc system now means all classes are exported!(?) Is this really true? Is there a way to NOT export a class within a shared library under gcc? #ifndef WIN32 #define __IMPEXP__ #else #undef __IMPEXP__ #ifdef __BUILDING_PULSETRACKER__ #define __IMPEXP__ __declspec(dllexport) #else #define __IMPEXP__ _

How to build from multiple source files at once in Eclipse

我的未来我决定 提交于 2019-12-14 03:25:11
问题 I have an Eclipse C++ project which initially has first.cpp . Then second.cpp is added and should be linked to the original file. Using Eclipse building tool, I got this output: make all Building file: ../src/first.cpp Invoking: GCC C++ Compiler g++ -I/home/workspace/first/src -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/first.d" -MT"src/first.o" -o "src/first.o" "../src/first.cpp" Finished building: ../src/first.cpp Building file: ../src/second.cpp Invoking: GCC C++ Compiler g++ -I