I've been reading about thread-safe singleton patterns here:
http://en.wikipedia.org/wiki/Singleton_pattern#C.2B.2B_.28using_pthreads.29
And it says at the bottom that the only safe way is to use pthread_once - which isn't available on Windows.
Is that the only way of guaranteeing thread safe initialisation?
I've read this thread on ...
What's the best stable C++ IDE with a GUI that runs on linux?
...
The following code:
template <typename S, typename T>
struct foo {
void bar();
};
template <typename T>
void foo <int, T>::bar() {
}
gives me the error
invalid use of incomplete type 'struct foo<int, T>'
declaration of 'struct foo<int, T>'
(I'm using gcc.) Is my syntax for partial specialization wrong? Note that if I remove the...
I have some c(++) code that uses sprintf to convert a uint_64 to a string. This needs to be portable to both linux and Solaris.
On linux we use %ju, but there does not appear to be any equivalent on Solaris. The closest I can find is %lu, but this produces incorrect output. Some sample code:
#include <stdio.h>
#include <sys/types.h>...
I have just started using Boost 1.36. These libraries would be very useful in reducing the amount of code needed in the unmanaged C++ software project that I am working on.
However when I tried to used these libraries my compile times increased ten fold. This would pretty much offset the productivity gains I would receive by using the l...
I would like to know if there is an easy way to detect if the text on the clipboard is in ISO 8859 or UTF-8 ?
Here is my current code:
COleDataObject obj;
if (obj.AttachClipboard())
{
if (obj.IsDataAvailable(CF_TEXT))
{
HGLOBAL hmem = obj.GetGlobalData(CF_TEXT);
CMemFile sf((BYTE*) ::GlobalLock(hmem),...
I don't know how to do this. Whenever I use the signal/slot editor dialog box, I have to choose from the existing list of slots. So the question is how do I create a custom named slot?
Thanks
...
I am analyzing a .dmp file that was created and I have a call stack which gives me a lot of info. But I'd like to double click on the call stack and have it bring me to the source code.
I can right click on the call stack and select symbol settings.. where I can put the location to the PDB. But there is no option for the source code...
I've noticed RAII has been getting lots of attention on Stackoverflow, but in my circles (mostly C++) RAII is so obvious its like asking what's a class or a destructor.
So I'm really curious if that's because I'm surrounded daily, by hard-core C++ programmers, and RAII just isn't that well known in general (including C++), or if all thi...
I would like to implement a robust IPC solution between a single JVM app (one process, potentially multiple threads) and a native C++ application that is linked to a C++ dll. The dll may or may not be on the same physical machine. What is the best approach for doing so?
Any suggestions will be greatly appreciated! Thanks!
...
I have a windows mobile 5.0 app, written in C++ MFC, with lots of dialogs. One of the devices I'm currently targetting does not have a tab key, so I would like to use another key to move between controls. This is fine for buttons but not edit controls or combo boxes. I have looked at a similar question but the answer does not really s...
I am facing a performance issue on a multi-core (8+) architecture with software written in C++ / VistualStudio / WindowsXP.
Suddenly I realized that I have no idea of the performances of my L1 and L2 cache and CPU->to->Memory bandwidth.
I have tested several tools (including VTune, Glowcode, etc, etc) but all of them fails when tested ...
what does it mean by value semantics and what is mean by implicit pointer semantics?
...
I have the following preprocessor divective:
#ifndef NDEBUG
#define TRACE printf
#else
#define TRACE(...)
#endif
and example of usage is:
TRACE("TRACE: some parameter = %i\n", param);
In C all works perfectly well when I build both debug and release versions, but in C++ compiler emits the following:
warning: invalid character in m...
If I want to call Bar() instead of Foo(), does Bar() return me a copy (additional overhead) of what Foo() returns, or it returns the same object which Foo() places on the temporary stack?
vector<int> Foo(){
vector<int> result;
result.push_back(1);
return result;
}
vector<int> Bar(){
return Foo();
}
...
I'm currently trying to pass a mono threaded program to multithread. This software do heavy usage of "refCounted" objects, which lead to some issues in multithread. I'm looking for some design pattern or something that might solve my problem.
The main problem is object deletion between thread, normally deletion only decrement the refere...
This semester, I took a course in computer graphics at my University. At the moment, we're starting to get into some of the more advanced stuff like heightmaps, averaging normals, tesselation etc.
I come from an object-oriented background, so I'm trying to put everything we do into reusable classes. I've had good success creating a came...
In a C++ file, I have a code like this:
#if ACTIVATE
# pragma message( "Activated" )
#else
# pragma message( "Not Activated")
#endif
I want to set this ACTIVE define to 1 with the msbuild command line.
It tried this but it doesn't work:
msbuild /p:DefineConstants="ACTIVATE=1"
Any idea?
...
Hi,
We are using c++ to develop an application that runs in Windows CE 4 on an embedded system.
One of our constraint is that all the memory used by the application shall be allocated during startup only. We wrote a lot of containers and algorithms that are using only preallocated memory instead of allocating new one.
Do you think it...
I am attempting to write an application that uses libCurl to post soap requests to a secure web service. This windows application is built against libCurl version 7.19.0 which, in turn, is built against openssl-0.9.8i. The pertinent curl related code follows:
FILE *input_file = fopen(current->post_file_name.c_str(), "rb");
FILE *out...