g++

C++ g++ thread-safety constructors

Given: class Foo { Foo() {}; }; class Bar { static int counter; Bar() { ++counter; } } It's clear that Foo::Foo is thread safe whereas Bar::bar is not. Furthermore, it's clear that if a function is written in such a way so that it's not thread-safe, then clearly putting it in a constructor makes that constructor not thread saf...

How to make G++ preprocessor output a newline in a macro?

Hello, Is there a way in gcc/g++ 4.* to write a macro that expands into several lines? The following code: #define A X \ Y Expands into X Y I need a macro expanding into X Y ...

Set stack size in a makefile?

I know how to set the stack size to unlimited in the command line: ulimit -s unlimited And, in bash, when I set the stack size to unlimited, my code runs and terminates successfully. Can I set the stack size to unlimited (or some specified size) in a makefile (with g++ as the compiler)? If so, how? Note: I can only submit my source ...

undefined referance to LibSerial

So i'm writing a serial transmision program, and have just changed over to using C++, it been a while since I used C++ (I've been working with C recently, and before that java) Now I need to use LibSerial, (it seems much simpler to use than C's termios) my code is: //gen1.cpp #include "string2num.h" // a custom header #include <iostr...

llvm preprocessor g++ passes

Suppose I want to write my own preprocessor. So I want something like this: all *.cpp and *.hpp (even the included ones), before they go to g++, they go: file --> my preprocessor -> g++ Is there a easy way to do this in the LLVM framework? i.e. to add in a stage that says: "after you load up the source file, pipe it through this pro...

Profiling g++ app on MacOSX?

My standard Linux way of profiling app is: 1) compile with g++ -pg 2) run prog 3) gprof Apparently gprof is broek on MacOSX 10.5, and I am supposed to use Shark. All the tutorials I've found aby Shark involves XCode (whereas my build is done with Makefiels and g++). Can someone post step by step instructions for using shark on an app...

Can I determine which compiler/linker flags where used to create a binary-only shared library ?

I am wondering if there is a way to find out which g++ compiler/linker flags where used in creating a binary-only library. For example there might be a 3rd party shared library (only .h/.so files are there). So I think it would be a good idea to use the same g++ flags when compiling and linking my own application (that is using the bin...

Invalid use of incomplete type on g++

I have two classes that depend on each other: class Foo; //forward declaration template <typename T> class Bar { public: Foo* foo_ptr; void DoSomething() { foo_ptr->DoSomething(); } }; class Foo { public: Bar<Foo>* bar_ptr; void DoSomething() { bar_ptr->DoSomething(); } }; When I compile it in...

Using Debian tools for building g++

I would like to rebuild g++ with my own specific settings. Here is what I did so far: sudo aptitude install build-dep g++-4.2 mkdir trial && cd trial apt-get source g++-4.2 Now I want to configure my specific settings. For g++ this is normally done by e.g. sh configure --prefix=/home/voku/non-productive But unfortunately I cannot ...

Can linking with the same library twice be a problem with g++?

I noticed that when I make my application with gcc and look at the output during the linking phase, I see the following lib included twice: /home/rb01/opt/trx-HEAD/gcc/4.2.4/lib/../lib64/libstdc++.so And so I was just wondering if this is a problem with g++ (gcc) or if the second one is simply ignored? Thanks! ...

Need Help regarding compiling Direct Sound using MinGW or any other C++ compiler if MinGW is not a very viable option

Hello, My problem is that I am trying to create a DLL of a C++ project which uses Direct Sound source and header files. There is a file called dsound.lib which i need to include. When I compile my code I get following errors Compiling source file(s)... RtAudio.cpp RtAudio.cpp:3477:20: dsound.h: No such file or directory RtAudio.cpp: In ...

How do i add a mclmcrrt.lib or (.lib) file when compiling with g++ Compiler

I have a algorithm code which uses matlab library(mclmcrrt.lib) it compiles well in my vc++ compiler when i add that library to it. My question is if i want to compile it on Linux g++ compiler how should i link the library can i use it? ...

How do I capture all of my compiler's output to a file?

Hello, I'm building an opensource project from source (CPP) in Linux. This is the order: $CFLAGS="-g Wall" CXXFLAGS="-g Wall" ../trunk/configure --prefix=/somepath/ --host=i386-pc --target=i386-pc $make While compiling I'm getting lot of compiler warnings. I want to start fixing them. My question is how to capture all the compiler o...

Undefined reference resulting from g++ linking

Hi there, I am new to g++ and Makefile. I am trying to link this BeBOP SMC library, which is in my lib directory. Under the lib directory are bebop_util and sparse_matrix_converter, both of which have already been built without errors. I see libbebop_util.a, libbebop_util.so under bebop_util and libsparse_matrix_converter.a, libsparse_m...

Using .lib and .dll files in Linux

Hi all, I have to make a project to run successfully on a Linux machine. Right now my project works very well on windows machine. On Windows machine it is compiling and working fine. My project is using one ".lib" and one ".dll" file to do the tasks successfully on Windows. Can i use the same .lib file and .dll file on linux machine to...

C++ libpthread program segfaults for unknown reason

Hi I have a libpthread linked application. The core of the application are two FIFOs shared by four threads ( two threads per one FIFO that is ;). The FIFO class is synchronized using pthread mutexes and it stores pointers to big classes ( containing buffers of about 4kb size ) allocated inside static memory using overloaded new and del...

Invalid free while performing a std::string assign with -O2 set in g++

Before I get blasted on opening another question, this question is related to another question that I opened a few days ago: http://stackoverflow.com/questions/2303740/c-program-always-crashes-while-doing-a-stdstring-assign After investigating further based on some of the answers I came up with more questions and more information that ...

Problem with boost::variant, linker giving a segfault

I have a boost variant with 7 types in it. When I try to use the last two types, the linker segfaults. I am using g++ (gcc version 3.3.3 on SuSE Linux) on a 64 bit linux machine and the error that I get is collect2: ld terminated with signal 11 [Segmentation fault] It doesnt matter what order I put the types in, the last two will cau...

g++ language and CRT reference

My working environment is Linux, Eclipse CDT and g++ 4.4. Where can I find language and CRT functions reference for this environment? WEB, or maybe it is always installed on my computer? ...

g++ fails mysteriously only if a .h is in a certain directory

I'm experiencing an extremely weird problem in a fresh OSX 10.4.11 + Xcode 2.5 installation. I've reduced it to a minimal test case. Here's test.cpp: #include "macros.h" int main (void) { return 1; } And here's macros.h: #ifndef __JUST_TESTING__ #define __JUST_TESTING__ template<typename T> void swap (T& pT1, T& pT2) { T pT...