g++

Handle std::thread::hardware_concurrency()

允我心安 提交于 2020-01-12 06:08:05
问题 In my question about std::thread , I was advised to use std::thread::hardware_concurrency() . I read somewhere (which I can not find it and seems like a local repository of code or something), that this feature is not implemented for versions of g++ prior to 4.8. As a matter of fact, I was the at the same victim position as this user. The function will simply return 0. I found in this answer a user implementation. Comments on whether this answer is good or not are welcome! So I would like to

gcc: Difference between -L and -l option AND how to provide complete path to a library

最后都变了- 提交于 2020-01-12 05:04:39
问题 I am new to makefile stuff; so, please accept my apology if my questions are trivials. Question 1 : What is the difference between -L and -l option. Question 2 : How do you provide complete path to some library? For instance, "libeng" and "libmx", mentioned in following makefile,are located at {MATLABROOT}/bin/glnxa64 # root directory of MATLAB installation MATLABROOT="/usr/local/MATLAB/R2011b" all: engdemo engdemo: g++ ${MATLABROOT}/extern/examples/eng_mat/engdemo.cpp -o engdemo \ -I$

gcc: Difference between -L and -l option AND how to provide complete path to a library

余生长醉 提交于 2020-01-12 05:04:22
问题 I am new to makefile stuff; so, please accept my apology if my questions are trivials. Question 1 : What is the difference between -L and -l option. Question 2 : How do you provide complete path to some library? For instance, "libeng" and "libmx", mentioned in following makefile,are located at {MATLABROOT}/bin/glnxa64 # root directory of MATLAB installation MATLABROOT="/usr/local/MATLAB/R2011b" all: engdemo engdemo: g++ ${MATLABROOT}/extern/examples/eng_mat/engdemo.cpp -o engdemo \ -I$

gcc: Difference between -L and -l option AND how to provide complete path to a library

元气小坏坏 提交于 2020-01-12 05:04:09
问题 I am new to makefile stuff; so, please accept my apology if my questions are trivials. Question 1 : What is the difference between -L and -l option. Question 2 : How do you provide complete path to some library? For instance, "libeng" and "libmx", mentioned in following makefile,are located at {MATLABROOT}/bin/glnxa64 # root directory of MATLAB installation MATLABROOT="/usr/local/MATLAB/R2011b" all: engdemo engdemo: g++ ${MATLABROOT}/extern/examples/eng_mat/engdemo.cpp -o engdemo \ -I$

Simple makefile with release and debug builds - Best practices

血红的双手。 提交于 2020-01-11 17:38:11
问题 I am new to makefiles. I learned makefile creation and other related concepts from "Managing projects with GNU make" book. The makefile is ready now and I need to make sure the one which I created is OK. Here is the makefile #Main makefile which does the build #makedepend flags DFLAGS = #Compiler flags #if mode variable is empty, setting debug build mode ifeq ($(mode),release) CFLAGS = -Wall else mode = debug CFLAGS = -g -Wall endif CC = g++ PROG = fooexe #each module will append the source

Missing default argument - compiler error

谁都会走 提交于 2020-01-11 17:09:31
问题 void func ( string word = "hello", int b ) { // some jobs } in another function //calling func ( "", 10 ) ; When I have compiled it, compiler emits error ; default argument missing for parameter How can I fix it without changing anything, of course, such as not making "int b = 0" ? Moreover, I want use that function like func ( 10 ) or func ( "hi" ) ? Is my compiler not do its job, properly ? 回答1: You can't have non-default parameters after your default parameters begin. Put another way, how

Missing default argument - compiler error

折月煮酒 提交于 2020-01-11 17:09:30
问题 void func ( string word = "hello", int b ) { // some jobs } in another function //calling func ( "", 10 ) ; When I have compiled it, compiler emits error ; default argument missing for parameter How can I fix it without changing anything, of course, such as not making "int b = 0" ? Moreover, I want use that function like func ( 10 ) or func ( "hi" ) ? Is my compiler not do its job, properly ? 回答1: You can't have non-default parameters after your default parameters begin. Put another way, how

“No matching function for call error” with g++

 ̄綄美尐妖づ 提交于 2020-01-11 13:07:14
问题 I have a class A template<typename T> class A : public std::auto_ptr<T> { typedef std::auto_ptr<T> Super; public: A() : Super() { } A(T* t) : Super(t) { } A(A<T>& o) : Super(o) { } ... }; and IConstEnumerator template<typename T> struct IConstEnumerator { ... virtual IEnumerator<T>* GetEnumerator() = 0; virtual IConstEnumerator<T>* GetEnumerator() const = 0; }; When I run this code AP< IConstEnumerator<IPort> > pe = node.GetPorts().GetEnumerator(); ; I got errors from not finding correct

Upgrading to G++ 4.8 - exception_ptr.h Does not support exception propagation

半世苍凉 提交于 2020-01-11 10:36:21
问题 I'm trying to recompile a huge legacy app with g++ 4.8 in order debug a glibc detected memory corruption problem (using AddressSanitizer). Previously we used g++ 4.4.7. However, compilation fails with: /opt/rh/devtoolset-2/root/usr/include/c++/4.8.2/bits/exception_ptr.h:40:4: error: #error This platform does not support exception propagation. while compiling a custom exception handler (I guess). The custom exception handler uses exception_ptr in only one place: void reportOtherException(void)

Why does this C++11 std::regex example throw a regex_error exception? [duplicate]

房东的猫 提交于 2020-01-11 04:47:05
问题 This question already has answers here : Is gcc 4.8 or earlier buggy about regular expressions? (3 answers) Closed 6 years ago . Trying to learn how to use the new std::regex in C++11. But the example I tried is throwing a regex_error exception I don't understand. Here is my sample code: #include <iostream> #include <regex> int main() { std::string str = "xyzabc1xyzabc2xyzabc3abc4xyz"; std::regex re( "(abc[1234])" ); // <-- this line throws a C++ exception // also tried to do this: // std: