g++

How to fix a segmentation fault: 11 in c++?

风格不统一 提交于 2020-05-14 10:05:05
问题 I am currently working on a program that takes the mode from an array of numbers using a template function. The code will compile with no problems using g++ on my macOS (i.e. no errors, warnings, etc.). However when I run the code I get this output in the terminal: Segmentation fault: 11 Here is the code that I have: #include <stdexcept> #include <cstdio> #include <cstddef> template<typename T> T mode(const T* values, size_t length) { if (length < 0) throw std::out_of_range{ 0 }; T result{};

NASM call for external C++ function

自古美人都是妖i 提交于 2020-05-09 06:35:10
问题 I am trying to call external C++ function from NASM. As I was searching on google I did not find any related solution. C++ void kernel_main() { char* vidmem = (char*)0xb8000; /* And so on... */ } NASM ;Some calls before section .text ;nothing special here global start extern kernel_main ;our problem After running compiling these two files I am getting this error: kernel.asm(.text+0xe): undefined reference to kernel_main' What is wrong here? Thanks. 回答1: There is no standardized method of

May I declare a member type alias to a type in a surrounding scope, using the same name?

江枫思渺然 提交于 2020-04-29 08:17:28
问题 I want a struct to contain a type alias to another type for metaprogramming purposes: struct Foo {}; struct WithNestedTypeAlias { using Foo = Foo; }; Then I can do stuff like WithNestedTypeAlias::Foo in a template etc. As I understand, this type alias is valid because it does not change the meaning of the Foo type. Clang compiles this happily. However, GCC complains: test-shadow-alias.cpp:4:20: error: declaration of ‘using Foo = struct Foo’ [-fpermissive] using Foo = Foo; ^ test-shadow-alias

How do I install g++ for Fedora?

六眼飞鱼酱① 提交于 2020-04-29 04:29:06
问题 How do I install g++ for Fedora Linux? I have been searching the dnf command to install g++ but didn't find anything. How do I install it? I have already installed gcc 回答1: The package you're looking for is confusingly named gcc-c++. 回答2: instead of g++ you have to write gcc-c++ sudo dnf install gcc-c++ 回答3: You should exec: dnf install gcc-c++ 回答4: I had the same problem. At least I could solve it with this: sudo yum install gcc gcc-c++ Hope it solves your problem too. 回答5: try sudo dnf

How do I install g++ for Fedora?

半腔热情 提交于 2020-04-29 04:28:19
问题 How do I install g++ for Fedora Linux? I have been searching the dnf command to install g++ but didn't find anything. How do I install it? I have already installed gcc 回答1: The package you're looking for is confusingly named gcc-c++. 回答2: instead of g++ you have to write gcc-c++ sudo dnf install gcc-c++ 回答3: You should exec: dnf install gcc-c++ 回答4: I had the same problem. At least I could solve it with this: sudo yum install gcc gcc-c++ Hope it solves your problem too. 回答5: try sudo dnf

Compiling c++ OpenACC parallel CPU code using GCC (G++)

眉间皱痕 提交于 2020-04-18 05:36:14
问题 When trying to compile OpenACC code with GCC-9.3.0 (g++) configured with --enable-languages=c,c++,lto --disable-multilib the following code does not use multiple cores, whereas if the same code is compiled with the pgc++ compiler it does use multiple cores. g++ compilation: g++ -lgomp -Ofast -o jsolve -fopenacc jsolvec.cpp pgc++ compilation: pgc++ -o jsolvec.exe jsolvec.cpp -fast -Minfo=opt -ta=multicore Code from OpenACC Tutorial1/solver https://github.com/OpenACCuserGroup/openacc-users

Parsing compilation error: no matching function for call to 'std::pair<,>::pair()'

早过忘川 提交于 2020-04-18 05:29:22
问题 This is a followup question to assigning-of-unordered-map-to-pair-of-objects. This is a question about the interpretation of the compiler errors (and not a repeat question, as that question was already fully answered). I was asked whether I took a look at the errors, and to post the errors so that others might benefit from an understanding. This is the first error for this: #include <bits/stdc++.h> using namespace std; struct foo { int n; foo(int n): n(n) {}; // foo(): n(0) {}; }; int main(){

Why does link_libraries(stdc++fs) work but not -lstdc++fs? [duplicate]

给你一囗甜甜゛ 提交于 2020-04-16 06:07:28
问题 This question already has an answer here : Flag '-l' in CMAKE_CXX_FLAGS doesn't work (1 answer) Closed 8 days ago . I was trying to compile a C++17 program on Ubuntu using CMake/g++ 8.1 which contained #include <filesystem> When I used this set(CMAKE_CXX_FLAGS "-lstdc++fs") I got a weird linker error undefined reference to `std::filesystem::__cxx11::recursive_directory_iterator::~recursive_directory_iterator()' This error also appeared when I tried calling g++ manually with the -lstdc++fs

G++ optimization beyond -O3/-Ofast

被刻印的时光 ゝ 提交于 2020-04-07 10:46:31
问题 The Problem We have a mid-sized program for a simulation task, that we need to optimize. We have already done our best optimizing the source to the limit of our programming skills, including profiling with Gprof and Valgrind. When finally finished, we want to run the program on several systems probably for some months. Therefore we are really interested in pushing the optimization to the limits. All systems will run Debian/Linux on relatively new hardware (Intel i5 or i7). The Question What

G++ optimization beyond -O3/-Ofast

允我心安 提交于 2020-04-07 10:46:11
问题 The Problem We have a mid-sized program for a simulation task, that we need to optimize. We have already done our best optimizing the source to the limit of our programming skills, including profiling with Gprof and Valgrind. When finally finished, we want to run the program on several systems probably for some months. Therefore we are really interested in pushing the optimization to the limits. All systems will run Debian/Linux on relatively new hardware (Intel i5 or i7). The Question What