g++

Piece of code that compiles with gcc but not g++ [duplicate]

对着背影说爱祢 提交于 2020-01-06 08:38:06
问题 This question already has answers here : Closed 9 years ago . Possible Duplicates: Is this a legitimate C++ code? “C subset of C++” -> Where not ? examples ? Could anybody come up with a piece of code that compiles with gcc or any other C compiler, and doesn't compile g++ or any other C++ compiler? UPDATE: I don't mean just keywords UPDATE2: Thank you All for answers. Apparently moderators were less enthusiastic than I was about subtle differences between C and C++. UPDATE3: to moderators:

g++ can't override exit function

我是研究僧i 提交于 2020-01-06 07:10:35
问题 I have a c++ program where I want to compile out std::exit and use my own, i.e. via: -Dexit=myExit However, I run into this issue: In file included from /usr/include/c++/7/ext/string_conversions.h:41:0, from /usr/include/c++/7/bits/basic_string.h:6352, from /usr/include/c++/7/string:52, from /usr/include/c++/7/bits/locale_classes.h:40, from /usr/include/c++/7/bits/ios_base.h:41, from /usr/include/c++/7/ios:42, from /usr/include/c++/7/istream:38, from /usr/include/c++/7/sstream:38, from tests

Cannot find sdl2main

人走茶凉 提交于 2020-01-06 07:05:06
问题 I'm trying to compile code using SDL, I can't really post much of the code here but I can do my best to answer questions about it. The problem occurs when compiling the view code and trying to link the SDL libraries. g++ -o test test.c -lSDL2main -lSDL2 gives me an error /usr/bin/ld: cannot find -lSDL2main I know my SDL install is okay because if I leave out the link to SDL2main it compiles fine and runs fine. The problem is there is other code that needs SDL2main. I've poured through my file

static library convert to a shared lib symbols are hidden?

余生颓废 提交于 2020-01-06 04:32:11
问题 I am trying to link v8's static library to a shared library using the following cmake command add_library(v8jni SHARED ${THIRDPARTY_LIB_PATH}/shared/v8jni.cpp) target_link_libraries(v8jni log -Wl,--whole-archive v8_inspector v8_base v8_snapshot v8_libplatform v8_libsampler v8_libbase -Wl,--no-whole-archive) libv8jni.so is generated successfully. But it's useless because all the v8 function are marked as local. nm -C libv8_base.a | grep v8::HandleScope 00000000 T v8::HandleScope::Initialize(v8

omp with gcc and intel compiler

主宰稳场 提交于 2020-01-06 01:56:50
问题 According to this question, the use of threadprivate with openmp is problematic. Here is a minimum (non-)working example of the problem: #include"omp.h" #include<iostream> extern const int a; #pragma omp threadprivate(a) const int a=2; void my_call(){ std::cout<<a<<std::endl; }; int main(){ #pragma omp parallel for for(unsigned int i=0;i<8;i++){ my_call(); } } This codes compiles with intel 15.0.2.164 but not with gcc 4.9.2-10. gcc says: g++ -std=c++11 -O3 -fopenmp -O3 -fopenmp test.cpp -o

C++ program compilation fails in Ubuntu, but works in MacOSX

拟墨画扇 提交于 2020-01-05 21:21:29
问题 Hi I've a program written in C++. When I compile it in Mac terminal with g++ compiler, it compiles and runs. But when I compile the same C++ program in Ubuntu terminal with g++ compiler, it Fails. I don't know why it happens. g++ compiler version in Ubuntu is 4.7.3. Here is my code sample #include <iostream> using namespace std; #define IXSIZE 400 #define IYSIZE 400 #define IZSIZE 3 void putbyte(FILE *outf, unsigned char val) { unsigned char buf[1]; buf[0] = val; fwrite(buf,1,1,outf); } void

What compiler option/library do I need to use detect_or_t type trait?

我的梦境 提交于 2020-01-05 14:09:15
问题 I am trying to use std::experimental::detect_or_t from <experimental/type_traits> . What compiler, option, version or library do I need to compile the following example from http://en.cppreference.com/w/cpp/experimental/is_detected ? #include <experimental/type_traits> #include <cstddef> template<class T> using diff_t = typename T::difference_type; template <class Ptr> using difference_type = std::experimental::detected_or_t<std::ptrdiff_t, diff_t, Ptr>; struct Meow { using difference_type =

How do I get make to figure out the correct dependencies to link in the correct downstream object files?

你离开我真会死。 提交于 2020-01-05 09:14:06
问题 I'm going to use a small example for reference. Consider a project with: inner_definitions.o : inner_definitions.cpp inner_definitions.h gcc $^ -o $@ inner_class_1.o : inner_class_1.cpp inner_class_1.h inner_definitions.h gcc $^ -o $@ inner_class_2.o : inner_class_2.cpp inner_class_2.h inner_definitions.h gcc $^ -o $@ outer_class.o : outer_class.cpp outer_class.h inner_class_1.h inner_class_2.h gcc $^ -o $@ executable.o : executable.cpp executable.h outer_class.h gcc $^ -o $@ executable : __

Specify external library for linux from Visual Studio 2017

≡放荡痞女 提交于 2020-01-05 09:06:50
问题 I'm developing linux(ubuntu) c++ project from Visual Studio 2017. I want to integrate googletest into my code. I have installed googletest and run test example according following tutorial. Everything works fine when I run it from bash terminal using cmake. Now I need to run it using VS. For that I need to specify path to /usr/lib/libgtest.a from VS. I added /usr/lib into Linker->General->Additional Library Directories and added libgtest.a into Linker->Input->Additional Dependencies . But

Enable compiler warnings in Kdevelop

折月煮酒 提交于 2020-01-05 07:36:50
问题 I'm using Kdevelop for a simple C++ project. I know that Kdevelop uses CMake to build the project, but the only thing that I known about CMake is that if I add a new .cpp source file in my project, I have to add it also in CMakeLists.txt . Now I'm trying to enable tha gcc compiler warnings (i.e. compiling with g++ -Wall ... ). Does Kdevelop have a compiler settings section, or I have to edit directly the Makefile or another CMake settings file? 回答1: You can add compiler flags in CMake by