g++

g++ variadic template issue

天涯浪子 提交于 2020-01-11 04:40:07
问题 So I gave this program to g++ and clang (both on Linux, x86_64): #include <iostream> using namespace std; template<char... Cs> struct A { static const string s; static A a; ~A() { cout << "s = " << s << "\n"; } }; template<char... Cs> const string A<Cs...>::s = {{Cs...}}; template<char... Cs> A<Cs...> A<Cs...>::a; int main(void) { (void)A<'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a'>::a; return 0; } Clang outputs s = aaaaaaaaaaaaaaaa (as expected). g++

In GCC, can precompiled headers be included from other headers?

☆樱花仙子☆ 提交于 2020-01-11 04:16:06
问题 When I compile a c++ file that includes a precompiled header, everything works as expected // test.c++ #include <precompiled.h> #include <header.h> main() {} > g++-4.7 --std=c++11 BLAH... test.c++ -H 2>&1 | grep precompiled.h ! precompiled.h.gch (! means that gcc found and used the precompiled header) However, when I put #include < precompiled.h > into header.h, it doesn't work: // test.c++ #include <header.h> main() {} > g++-4.7 --std=c++11 BLAH... test.c++ -H 2>&1 | grep precompiled.h .

Bloated EXE sizes, and unwanted dependencies with Qt/MingW

安稳与你 提交于 2020-01-11 03:11:38
问题 I'm trying to figure out how to shrink the sizes of EXE files compiled under the newest QT SDK (4.8.2) (mingw/g++ based). I was working on a vanilla c++ console app that has a simple loop and only #includes iostream, when I noticed that the exe's it generated are about 465kb; way bigger than they should be! Commenting out all the stream stuff brings it down to the expected 5kb range (although the remaining code would be mostly dead). This doesn't seem right at all, especially since another,

Override a C function defined in a static library

孤者浪人 提交于 2020-01-10 03:55:06
问题 I have a static library of C files, compiled with g++ on Cygwin. I wish to unit test one function that is defined in the library. That function calls another function defined in that library and I wish to override the dependency to replace it with my own version of that function. I can't modify what's in the static library, so this solution [ Override a function call in C ] doesn't apply. Usually, I can write a .cpp file and include the .c file containing the function I want to unit test,

How can you compile all cpp files in a directory?

余生长醉 提交于 2020-01-10 02:56:07
问题 I have a number of source files in a number of folders.. Is there a way to just compile all of them in one go without having to name them? I know that I can say g++ -o out *.cpp But when I try g++ -o out *.cpp folder/*.cpp I get an error. What's the correct way to do this? I know it's possible with makefiles, but can it be done with just straight g++? 回答1: By specifying folder/*.cpp you are telling g++ to compile cpp files in folder . That is correct. What you may be missing is telling the g+

Valgrind reports memory leak when assigning a value to a string

谁说我不能喝 提交于 2020-01-09 10:42:45
问题 Valgrind reports a memory leak when assigning a value to a string. I used the following simple code to test an memory leak reported by Valgrind. /****************************************** * FILE: t3.c * Compiled using : g++ -g t3.c -o t3 * * $ g++ -v * Reading specs from /usr/lib/gcc/i686-pc-linux-gnu/3.4.6/specs * Configured with: ./configure --prefix=/usr --infodir=/share/info --mandir=/share/man * --enable-languages=c,c++ --with-system-zlib --program-suffix=-3.4 --enable-threads=posix *

Help compiling with gcc/g++

我只是一个虾纸丫 提交于 2020-01-07 04:20:49
问题 If I have a directory structure such as the tree below, what should my g++ command look like that would successfully compile the .cpp file that is in the taglib/bin dir, with all my .h files sitting in the taglib/include/taglib directory. Anyones help would be greatly appreciated. Thank you! -taglib --bin .cpp file is here, incl headers are like this: #include <other.h> but wondering if it should be #include </taglib/include/taglib/other.h>, also, this should be where my binary will live when

Using libraries compiled for Windows on Linux

。_饼干妹妹 提交于 2020-01-07 00:31:13
问题 I'm curious. I have a library (static and dynamic version) compiled with visual studio for Windows 64bit which I want to use on Linux. This is a commercial library and to get the same library compiled for Linux will take many days of emailing and reminding and so on and so on. Can I use one of these two library variants (and these are not .net, but native libraries) to link to them on Linux machine? 回答1: Theoretically, you should be able to do so. It would be an awful lot of work, but this is

Eclipse CDT (Juno) in Win7: Cannot find g++ in PATH, iostream unresolved and other fun stuff

╄→гoц情女王★ 提交于 2020-01-06 19:30:01
问题 I'm coming here out of desperation, you guys are my last string of hope. I've been having the problems in the title since yesterday and for the life of me I cannot find what's wrong. A simple hello world program cannot be built as Eclipse fails to find the g++ compiler. I've managed to find the PATH variable in Project->Properties->C++ BuildEnvironment and it's set at C:\Users\Dimitris\Documents\eclipseCPP\eclipse;C:\Program Files (x86)\AMD APP\bin\x86_64;C:\Program Files (x86)\AMD APP\bin

Hello World project will not compile

狂风中的少年 提交于 2020-01-06 08:51:10
问题 I recently started using Eclipse CDT for developing C++ applications. I downloaded the Eclpse Kepler CDT bundle, and it opened up properly, but when i created a simple hello world application I was getting an error"Binary Not Found", even after building the project. Ill show you what my console display 19:54:11 **** Incremental Build of configuration Debug for project HelloWorld **** make all Building file: ../src/HelloWorld.cpp Invoking: GCC C++ Compiler g++ -O0 -g3 -Wall -c -fmessage-length