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...
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
...
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 ...
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...
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...
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...
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...
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...
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 ...
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!
...
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 ...
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?
...
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...
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...
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...
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...
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 ...
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...
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?
...
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...