The following code runs perfectly well on my XP SP2 machine, but the call to WaitForSingleObject waits indefinitely when running on my Vista machine:
HANDLE ghSemaphore;
ghSemaphore = CreateSemaphore(NULL, 0, 1, "COM_PHILOERTEL_FINA");
if (ghSemaphore == NULL) {
MessageBoxA(NULL,"Error creating semaphore","ERROR",0);
return FALSE;
}
...
Suppose I want to pass a temporary object into a function. Is there a way to do that in 1 line of code vs. 2, with a struct?
With a class, I can do:
class_func(TestClass(5, 7));
given:
class TestClass
{
private:
int a;
short b;
public:
TestClass(int a_a, short a_b) : a(a_a), b(a_b)
{
}
int A() const
...
I'm trying to make a Trie data structure (school work) and I'm using a list which I've also made myself and works fine (tested) to store the N-nodes in the Trie.
Anyway, the problem is, every node is supposed to store a list of nodes so I can make my N-ary tree/trie but I've hit a snag...
When I'm debugging and going through the for lo...
Does anyone know how to use a void pointer to generate a 2D array rather than an int pointer?
For integer pointer, I do as follow:
int **m;
m = new int* [row];
for(int i=0; i< row; i++)
m[i] = new int[col];
for (int i = 0; i < row; i++)
for (int j = 0; j < col; j++)
m[i][j] = rand () % 10;
What...
I am attempting to use the QT QNetworkAccessManager class to manage some downloads in a multi-threaded C++/QT application.
On worker thread (edit: the thread is seperate for other reasons aside from doing the download), I'm would like to do a get to an external server and be ready to receive the results with the code:
...
m_nam = new ...
Hello,
I've worked myself through the rapidXML sources and managed to read some values. Now I want to change them and save them to my XML file:
Parsing file and set a pointer
void SettingsHandler::getConfigFile() {
pcSourceConfig = parsing->readFileInChar(CONF);
cfg.parse<0>(pcSourceConfig);
}
Reading values from XML
void ...
Besides __ LINE__ and __ FILE__
are there other useful pre-defined macros, like
__ FUNCTION_NAME__
?
If not, but you know of other cool/useful defined macros (especially for debugging purposes), I'd love to hear about them.
EDIT: some have asked about platform:
I'm using gcc/g++ on MacOSX.
...
I want to define a class MyStream so that:
MyStream myStream;
myStream << 1 << 2 << 3 << std::endl << 5 << 6 << std::endl << 7 << 8 << std::endl;
gives output
[blah]123
[blah]56
[blah]78
Basically, I want a "[blah]" inserted at the front, then inserted after every non terminating std::endl ?
The difficulty here is NOT the logic ma...
I am generating the vertex arrays on the fly on each render and I want to delete the arrays afterwards. Does glDrawArrays immediately copy the vertex arrays to the server? Hence is it safe to delete the vertex arrays after calling glDrawArrays?
float * vp = GetVertices(); // Regenerated on each render
glVertexPointer(3, GL_FLOAT, 3 * s...
Hello,
I have an application which makes use of winsock.
I/O part is handled on an other thread.
And I am using blocking select method for sockets.
But the point is that after 5-6 hours,my application gives 0xC00000FD exception, at the line of select function.
As far as I know, this exception occurs when there is recursion, or very l...
Hello,
I'm building a C++ command line tool in Xcode. The project contains dylibs for curl, boost and log4cpp.
Ideally id like to build an i386 universal binary that supports 10.4 through to 10.6.
I cant seem to get Xcode to compile, when I target 10.4 it says things like no such file or directory.
When i target 10.6 x_64 it builds ...
We recently received a report that our application will occasionally fail to run. I tracked down the problem code to this:
struct ARRAY2D
{
long[] col;
}
int numRows = 800000;
int numCols = 300;
array = (ARRAY2D*) malloc(numRows * numCols * sizeof(long))
This allocation of 800 Mb can fail if the user doesn't have a large enough fr...
When I add many different timeouts (with each intervall==0) in a thread, which is not the main thread (where gtk_main() resides)...
g_timeout_add(0, func, NULL);
... will then the different func() callbacks occur in the same order I called the corresponding g_timeout_add()'s?
The reason I'm asking is because GTK# is using internally...
I'd like to know the precise yet succinct definitions of these three concepts in one place. The quality of the answer should depend on the following two points.
Show a simple code snippet to show how and what the concept/technique is used for.
Be simple enough to understand so that a programmer without any exposure to this area can gra...
Hello,
I'm trying to build the boost libraries and others against the os x 10.4u.sdk so I can include them in a project targeting 10.4 upwards.
I'm not entirely sure what to do, am I aiming to put the .dylibs in 10.4.sdk/usr/local/.. or in my default 10.6 /usr/local/.. with support for 10.4?
Any help much appreciated.
Toby.
...
I have the problem that i am using relative paths for my files, so when i use "open with" method for opening a file into my program, all my paths are screwed (it will create my files in the folder where i used this "open with" method.)
How i can retrieve the full path to the .exe file that im using to open the file with "open with" meth...
I'm learning C++ at the moment and though I grasp the concept of pointers and references for the better part, some things are unclear.
Say I have the following code (assume Rectangle is valid, the actual code is not important):
#include <iostream>
#include "Rectangle.h"
void changestuff(Rectangle& rec);
int main()
{
Rectangle rect...
llvm-config puts -fno-exceptions in the LDFLAGS for linking llvm itself. Am I right in assuming this means that I cannot use normal C++ try/throw blocks in code (such as a new language front-end) that link against the llvm compiler? I'm not talking about programs the compiler produces, but the compiler itself. I do not want to meddle ...
I'm a little confused as to the mechanics of the copy constructor. Correct me if I'm wrong:
If a method takes a reference to an object as a parameter, and the class defines a copy construtor, then the class uses the constructor to create a copy of itself and that gets passed to the function instead of a reference to the original object...
So I'm working on this event management class. I'm storing a list of pointers to member functions of the signature void (Event*) where Event is just a struct that stores some random data at the moment.
typedef boost::function<void(Event*)> Callback;
typedef vector<Callback> CallbackList;
class EventManager
{
public:
template<typenam...