g++

How to enable optimization in G++ with #pragma

妖精的绣舞 提交于 2020-01-01 05:08:50
问题 I want to enable optimization in g++ without command line parameter. I know GCC can do it by writing #pragma GCC optimize (2) in my code. But it seems won't work in G++. This page may help: http://gcc.gnu.org/onlinedocs/gcc/Function-Specific-Option-Pragmas.html My compiler version: $ g++ --version g++ (Ubuntu/Linaro 4.6.1-9ubuntu3) 4.6.1 <suppressed copyright message> $ gcc --version gcc (Ubuntu/Linaro 4.6.1-9ubuntu3) 4.6.1 <suppressed copyright message> I worte some code like this: #pragma

gcc understand where compilation time is taken

你离开我真会死。 提交于 2020-01-01 04:46:25
问题 I have a project that makes massive use of templates. Recently the compilation time rose quite abruptly. I wonder if there's a way for seeing what classes / lines require the most time to be compiled by g++. Here is some output from -ftime-report Execution times (seconds) TOTAL : 0.30 0.05 0.37 9119 kB Execution times (seconds) garbage collection : 0.91 ( 6%) usr 0.00 ( 0%) sys 0.92 ( 5%) wall 0 kB ( 0%) ggc callgraph construction: 0.23 ( 2%) usr 0.11 ( 3%) sys 0.37 ( 2%) wall 10652 kB ( 1%)

How to install g++ 4.9 on Debian Wheezy armel?

不羁岁月 提交于 2020-01-01 04:30:12
问题 My Debian 7 armel embedded system currently has g++ 4.6, and I'd like to upgrade to g++ 4.9 to use new C++11 features. How do I do that? My current sources.list contents is: deb http://security.debian.org/ wheezy/updates main deb-src http://security.debian.org/ wheezy/updates main deb http://ftp.us.debian.org/debian wheezy main non-free deb-src http://ftp.us.debian.org/debian wheezy main non-free A simple apt-get install of the package does not work: root@arm:~# apt-get install g++-4.9

gcc with parameters “-S -save-temps” puts intermediate files in current directory

老子叫甜甜 提交于 2020-01-01 04:19:32
问题 The parameters -S -save-temps work fine, as long as i don't use them on files with the same name. Think of the following situation: I have a project with a main directory and a subdirectory with the name subDir and in both of the directories are files placed with the name file.c . If I now call gcc -S -save-temps file.cpp subDir/file.c only one intermediate file with the name file.i will be generated. That is the expected behaviour, as the man file of gcc tells me, that the intermediate files

Clang and GCC disagree in auto specifier for non-type template parameter in a casting C++17

£可爱£侵袭症+ 提交于 2020-01-01 04:04:05
问题 I basically have a class that depends on a non-type template parameter. I defined a casting so an object of non-type template parameter N can convert to another of M . I have a minimal example that can reproduce the situation: template<auto Integral> class Test{ public: typedef decltype(Integral) value_type; static constexpr value_type N = Integral; constexpr Test (const value_type& x = 0); template<auto Integral2> constexpr explicit operator Test<Integral2>() const; private: value_type n; };

Clang and GCC disagree in auto specifier for non-type template parameter in a casting C++17

吃可爱长大的小学妹 提交于 2020-01-01 04:04:01
问题 I basically have a class that depends on a non-type template parameter. I defined a casting so an object of non-type template parameter N can convert to another of M . I have a minimal example that can reproduce the situation: template<auto Integral> class Test{ public: typedef decltype(Integral) value_type; static constexpr value_type N = Integral; constexpr Test (const value_type& x = 0); template<auto Integral2> constexpr explicit operator Test<Integral2>() const; private: value_type n; };

How to run C++ application in Android SHELL

老子叫甜甜 提交于 2020-01-01 02:51:26
问题 I want to run hello world written on C++ and compiled with Android toolchain 9 , but I faced with issue: by default I have no permissions to launch it and I can't change permissions using chmod`. I used Android 2.3.3 - Api Level 10 Application was compiled by cross compiler for API level 9 Procedure: Compile application: ~/toolchain_andr9/bin/ arm-linux-androideabi-g++ helloworld.cpp Then send application to SDCARD on the emulator: >adb push a.out /mnt/sdcard then go to SHELL and try to run a

Simulating case sensitivity on a filesystem that isn't case sensitive

拟墨画扇 提交于 2020-01-01 02:47:05
问题 When I develop in C++ on a filesystem that is not case sensitive, I miss problems such as #include "File.h" if on disk it is actually file.h . The problem only appears when I eventually try to compile the code on a case sensitive filesystem. How do I simulate case sensitivity on a filesystem (such as OSX's default) that isn't case sensitive? Edit: I am looking for an automated solution, one that I can run now and in the future with "the push of a button". It also appears to be perfectly good

What does frame_dummy mean in the context of profiling?

这一生的挚爱 提交于 2020-01-01 02:16:08
问题 In the process of using gprof to profile a C++ program I've written, I've noticed that the vast majority of execution time is spent in the function "frame_dummy". More precisely, the first entry in the flat profile from the output of gprof shows 76.38% of sample time spent in and 24611191 calls to a function with name frame_dummy. In short, I am trying to understand both what frame_dummy refers to -- as I do not have any function named as such -- as well as what this means for my optimization

Why am I allowed to copy unique_ptr? [duplicate]

試著忘記壹切 提交于 2020-01-01 01:52:12
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: Returning unique_ptr from functions 20.7.1.2 [unique.ptr.single] defines copy constructor like this : // disable copy from lvalue unique_ptr(const unique_ptr&) = delete; unique_ptr& operator=(const unique_ptr&) = delete; So, why the following code compiles fine? #include <memory> #include <iostream> std::unique_ptr< int > bar() { std::unique_ptr< int > p( new int(4)); return p; } int main() { auto p = bar(); std