g++

Internal compiler error : segmentation fault with g++4.3.5

强颜欢笑 提交于 2021-02-20 05:39:04
问题 Here is the code //fail_.cpp template< unsigned char X, class L> class A { public: typedef void (A::*fptr)(); class B { public: B(typename A< X, L> ::fptr ); }; }; template < unsigned char X, typename L > A<X,L>::B::B ( fptr ) { } g++ -c fail_.cpp gives fail_.cpp:11: internal compiler error: Segmentation fault Please submit a full bug report, with preprocessed source if appropriate. See < file:///usr/share/doc/gcc-4.3/README.Bugs > for instructions. Looks like a bug to me in g++4.3.5, g++4.4

Combining FORTRAN and C++, linking error

為{幸葍}努か 提交于 2021-02-19 05:44:05
问题 I should couple in linux one c++ code with old fortran code, where fortan is the main code. Im not expert in this area and I try to start with simple test, but still I cannot compile it. Maybe I'm stupid, but I cannot find a working example anywhere. I managed to compile fortran and c, when the linking can be done by ifort (need to use intel compiler later with the actual fortran code). But If I've understood right, with c++ , the linking must be done by c++ compiler ( g++ ). So what do I do

Makefile output folder

≡放荡痞女 提交于 2021-02-17 05:45:09
问题 I have a makefile and all I want to do is to make my executable go to the folder created in the one I have all the files in. So let's say I have a folder in which there are some .cpp files, I create a folder in this folder called OUTPUT (during compilation) and I want my exec made out of those cpp files to go into this folder. How do i do that? Thanks in advance! 回答1: OUTPUT/exec: foo.cpp bar.cpp baz.cpp g++ $^ -o $@ Refinements are possible, but this will get you started. 来源: https:/

C++ Multithreading with MinGW

流过昼夜 提交于 2021-02-17 02:20:44
问题 I would like to experiment with multithreading with c++. I am using the MinGW g++ compiler (version 8.2.0) on Windows 10. When I try to use the builtin thread library with c++ using the code I got directly from a website, I get the error: main.cpp:34:5: error: 'thread' was not declared in this scope thread th1(foo, 3); ^~~~~~ main.cpp:34:5: note: 'std::thread' is defined in header ''; did you forget to '#include '? main.cpp:5:1: +#include using namespace std; main.cpp:34:5: thread th1(foo, 3)

How you create your own views that interact with existing views with operator |?

孤街醉人 提交于 2021-02-16 04:38:54
问题 Why does this code work with the #if 0 block in place, but fails with a fairly complex set of error messages if you remove it? And more importantly, how do I make it the same result as the very similar block above it? #include <ranges> #include <iterator> #include <optional> #include <string_view> #include <iostream> #include <algorithm> template <::std::ranges::view View, typename Pred> requires ::std::ranges::input_range<View> && ::std::ranges::common_range<View> && ::std::is_object_v<Pred>

How you create your own views that interact with existing views with operator |?

穿精又带淫゛_ 提交于 2021-02-16 04:36:33
问题 Why does this code work with the #if 0 block in place, but fails with a fairly complex set of error messages if you remove it? And more importantly, how do I make it the same result as the very similar block above it? #include <ranges> #include <iterator> #include <optional> #include <string_view> #include <iostream> #include <algorithm> template <::std::ranges::view View, typename Pred> requires ::std::ranges::input_range<View> && ::std::ranges::common_range<View> && ::std::is_object_v<Pred>

How you create your own views that interact with existing views with operator |?

妖精的绣舞 提交于 2021-02-16 04:35:41
问题 Why does this code work with the #if 0 block in place, but fails with a fairly complex set of error messages if you remove it? And more importantly, how do I make it the same result as the very similar block above it? #include <ranges> #include <iterator> #include <optional> #include <string_view> #include <iostream> #include <algorithm> template <::std::ranges::view View, typename Pred> requires ::std::ranges::input_range<View> && ::std::ranges::common_range<View> && ::std::is_object_v<Pred>

How to correctly define and link a C++ class destructor to a main file?

牧云@^-^@ 提交于 2021-02-11 07:20:24
问题 This is a particularized question from mingw32/bin/ld.exe ... undefined reference to [class] ... collect2.exe: error: ld returned 1 exit status There is a user-defined class inside MyClass.hpp: class MyClass { public: MyClass(const string& className); ~MyClass() {cout << "Destructor definition instead of g++ default one?";} ; ... and you try to construct an object out of it in the main file: #include "MyClass.hpp" //in the same directory ... int main() { ... MyClass myClassObj = MyClass

How to correctly define and link a C++ class destructor to a main file?

戏子无情 提交于 2021-02-11 07:20:06
问题 This is a particularized question from mingw32/bin/ld.exe ... undefined reference to [class] ... collect2.exe: error: ld returned 1 exit status There is a user-defined class inside MyClass.hpp: class MyClass { public: MyClass(const string& className); ~MyClass() {cout << "Destructor definition instead of g++ default one?";} ; ... and you try to construct an object out of it in the main file: #include "MyClass.hpp" //in the same directory ... int main() { ... MyClass myClassObj = MyClass

segmentation fault on a recursive function

南楼画角 提交于 2021-02-10 18:43:20
问题 I simply want to test something. I am wondering what I did wrong? #include <iostream> using namespace std; unsigned long pwr(unsigned long n, unsigned long m) { if(m == 0) n = 1; if(m == 1) n = n; n = pwr(n, m/2) * pwr(n, m/2); return n; } int main () { unsigned long n(2), m(16); cout << pwr(n, m); return 0; } output is Segmentation fault 回答1: There is no exit from recursion. You may wanted if(m == 0) n = 1; else if(m == 1) n = n; else n = pwr(n, m/2) * pwr(n, m/2); return n; 回答2: Infinite