c++

Is there anyway to dynamically free thread-local storage in the Win32 APIs?

I need to make use of thread-local storage in a cross-platform project. Under *IX I am using pthreads and can avoid memory leaks thanks to the nice destructor function pointer passed as the second argument to pthread_key_create, but in Windows TlsAlloc has no such thing. Nor can I find a general place where any function is called on thre...

Writing Unit-Tests in C++

Possible Duplicate: Comparison of c++ unit test frameworks Hello guys, I'm coming from .net to C++ and I want to know if there i good articles/information about unit-testing in c++ and the most used/best frameworks for doing it. Thanks in advance. ...

boost static_assert with message?

Hi, on 1.43 boost it seems that BOOST_STATIC_ASSERT just allows to put a boolean value, is there some alternative that allows me to display a message as well on the compile error? ...

Boost.Statechart - issue with documented method for choice points

As per the example in the documentation I made the following code that fails to compile because custom_reaction<> does not seem to match the concept expected as the third template parameter to state<>. How do I really make choice points? (I also asked this on the boost list) #include <boost/statechart/state_machine.hpp> #include <boost...

What is the error in the following g++ class construction?

I receive a g++ error (undefined reference to 'SomeClass::SomeClass(int)' and 'SomeClass::~SomeClass') with the following: /* * SomeClass.h * */ #ifndef SOMECLASS_H_ #define SOMECLASS_H_ class SomeClass { public: SomeClass(); SomeClass(int someInt); ~SomeClass(); }; #endif /* SOMECLASS_H_ */ /* * SomeClass.cpp * ...

Performance of .Net function calling (C# F#) VS C++

Since F# 2.0 has become a part of VS2010 I take an interest in F#. I wondered what's the point of using it. I'd read a bit and I made a benchmark to measure functions calling. I have used Ackermann's function :) C# sealed class Program { public static int ackermann(int m, int n) { if (m == 0) return n + 1; ...

Multiple Threads - do i need to lock on reading data?

look at this code: int data=5; void Thread1() { if(data==5) { //nothing } } void Thread2() { if(data==2) { //nothing } } in this case, do i need to use EnterCriticalSection/MutexLock before if(data==..) ? ...

How does GMP stores its integers, on an arbitrary number of bytes ?

2^64 is still far from the "infinity" my ram/hard drive can handle... First I wonder how GMP works with memory/processor since it does some kind of shady optimisations... I was also wondering if there is a way of storing an integer (unsigned, it's easier) on an arbitrary number of bytes. For example, on 50 bytes, I would have a cap of ...

Can I define a type based on the result of some calculation?

I perform some calculations, based on the result, I would like to either use a short int or int for some type of data for the remaining program. Can (/How can) this be done sensibly in C or C++? I don't really care about the amount of memory used (i.e., 2 or 4 bytes), my primary aim is to access generic arrays as if they contained data o...

SVG decoding - portable solution

I need fully functional vector format, which i can decode to plain bitmap data in my app. It doesn't need to be SVG, but it seemed best (but other suggestions are welcome). So, i need an lib to simply rasterize SVG into plain pixel data - the simplier, the better. The problem is I need it for bada OS (it's OS for mobile phones), so i nee...

Controlling how parameters are sent to superclass constructor from subclass constructor declaration (C++)

Can it be done? I am looking for something different than using the member initialization list (because that is present in the definition, not necessarily the declaration). Something like class(args) : superclass(fn of args); ...

How to create service which restarts on crash

I am creating a service using CreateService. The service will run again fine if it happens to crash and I would like to have Windows restart the service if it crashes. I know it is possible to set this up from the services msc see below. How can I programatically configure the service to always restart if it happens to crash. ...

Overloading operator++ prefix / postfix in terms of each other?

I have a question that may have been answered over 9000 times before but I really don't know how to word it, this is what I am going to try. I've seen in some C++ books and tutorials that when defining your own class which has a iterable value (incrementable) semantics, you can overload operator++ for it (all I'm going t state here I'd ...

fftw3 on windows 64-bit

I would like to use FFTW3 on Windows-64 bit. I follow the instructions on FFTW website: download the package, unzip, run lib.exe to create .lib "import libraries". After doing so, I build my application (which runs just fine using FFTW3 dlls 32-bit) and I get the following errors: 1>pyramidTransform.obj : error LNK2019: unresolved...

C++ vector pointer array

have struct_gene and struct_units. i read all Struck_gene values to vector. How do i assign pointer for struck_units.has_gene[i] to point to some value in struct_genevector so i dont have to write full copy of stuckt_gene And after that read it. I tried for some time but didn't manage to get working solution http://a.imageshack.us/img1...

Purging Preprocessing Macros

Hi! This is an odd problem, so I have to provide a bit of background. I have a C++ project that I'm working on that I want to clean up a bit. The main issue that I'm dealing with that makes me want to barf is the massive abuse of preprocessor macros that are used in a core component of the project. There's a file with a bunch of #define...

Scalable approach for handling timeout of various IPC requests

I have a server and a client. The client is capable of sending out various types of IPC requests. What are some proven approaches/frameworks for a generic timeout handling that can accomodate each type of request? Ideally, I would like to have: different behavior for handling timeout of different types of messages on client side, repo...

Can I configure Visual Studio to use real folders instead of filters in C++ projects?

It's annoying to have to separately maintain a .filters file to make Visual Studio happy, as well as my project's on-disk layout. Is it possible to tell VS to use real folders, like it does for C#? ...

What do you feel is over-generalization?

Having spent some time playing around in Haskell and other functional languages, I've come to appreciate the simplicity of design that comes from describing problems in general terms. While many aspects of template programming can be far from simple, some uses are common enough that I don't think they're an impediment to clarity (especia...

Why does this EXC_BAD_ACCESS happen with long long and not with int?

I've run into a EXC_BAD_ACCESS with a piece of code that deals with data serialization. The code only fails on device (iPhone) and not on simulator. It also fails only on certain data types. Here is a test code that reproduces the problem: template <typename T> void test_alignment() { // allocate memory and record the original addr...