c++

Inter-thread communication. How to send a signal to another thread

In my application I have two threads a "main thread" which is busy most of the time an "additional thread" which sends out some HTTP request and which blocks until it gets a response. However, the HTTP response can only be handled by the main thread, since it relies on it's thread-local-storage and on non-threadsafe functions. I'm l...

Link a member function directly to C method declared in a header

Can I link a member function like this in some way? redeclaring the method as a member and get it call the Mmsystem.h method to not have to wrap it? #include <windows.h> #include <Mmsystem.h> namespace SoundLib { public class CWave { public: // WaveIn call external UINT waveOutGetNumDevs(VOID); }; } ...

How to convert DirectShow Filter to C++\C#?

So we have some filter for DS. It works - uses standard win dll's. We want to convert that filter to some sort of non-using DS program. So we want it to call dlls in write order, do all what DS is doing but not be in any way dependable on DS - only on filter dll's. So... How to convert DirectShow Filter to C++\C#? ...

Qt, Signals without naming?

Is there any way to use the signals without MOC and without the connecting via names? My one problem with Qt is that you have something like this->connect(this->SaveBtn, SIGNAL(click()), SLOT(SaveClicked())); And there is no error detection to tell that is wrong other then finding out the button doesn't work or searching through their ...

Web interface for c++ applications

Hi, Our company has a set of 3d modeling softwares written in c++ with qt based gui. We are planning to offer these applications to customers to try them from a web browser. I mean to say, we need to create web interfaces for native c++ codes. Please suggest me which technology, languages should be used. If possible please give some...

Monitoring Active Directory events

How can I programatically detect any changes that occur to Microsoft's Active Directory? ...

Are memory leaks "undefined behavior" class problem in C++?

Turns out many innocently looking things are undefined behavior in C++. For example, once a non-null pointer has been delete'd even printing out that pointer value is undefined behavior. Now memory leaks are definitely bad. But what class situation are they - defined, undefined or what other class of behavior? ...

What's a good convex optimization library?

I am looking for a C++ library, and I am dealing with convex objective and constraint functions. ...

How to use SDL with OGRE?

When I go to use OGRE with SDL (as described in this article), I seem to be having trouble with a second window that appears behind my main render window. Basically, the code I'm using is this: SDL_init(SDL_INIT_VIDEO); SDL_Surface *screen = SDL_SetVideoMode(640, 480, 0, SDL_OPENGL); Ogre::Root *root = new Ogre::Root(); root->restoreC...

How to get Python code to work with C++ App?

I have the following python 3 file: import base64 import xxx str = xxx.GetString() str2 = base64.b64encode(str.encode()) str3 = str2.decode() print str3 xxx is a module exported by some C++ code. This script does not work because calling Py_InitModule on this script returns NULL. The weird thing is if I create a stub xxx.py in the sa...

How to solve a problem in using RAII code and non-RAII code together in C++?

We have 3 different libraries, each developed by a different developer, and each was (presumably) well designed. But since some of the libraries are using RAII and some don't, and some of the libraries are loaded dynamically, and the others aren't - it doesn't work. Each of the developers is saying that what he is doing is right, and ma...

Calculating the balance factor of a node in avl tree

I want to calculate the balance factor of a node in avl tree without using any recursive procedure. How can i do that? Please tell me method or provide C++ code snippet. ...

Comparison operations on ipv6 address using C++

hi As IPV6 address has 16 bytes and their is no data type to store it in c++, i wanted to store the IPV6 address, and do some comparisions between to IPv6 address, please let me know how to do it ...

Dynamically allocate C struct?

Hi, I want to dynamically allocate a C struct: typedef struct { short *offset; char *values; } swc; Both 'offset' and 'values' are supposed to be arrays, but their size is unknown until runtime. How can I dynamically allocate memory for my struct and the struct's arrays? ...

Is using "operator &" on a reference a portable C++ construct?

Suppose I have: void function1( Type* object ); //whatever implementation void function2( Type& object ) { function1( &object ); } supposing Type doesn't have an overloaded operator &() will this construct - using operator & on a reference - obtain the actual address of the object (variable of Type type) on all decently standard-c...

BOOST_STATIC_ASSERT without boost

Since boost is forbidden in a company I work for I need to implement its functionality in pure C++. I've looked into boost sources but they seem to be too complex to understand, at least for me. I know there is something called static_assert() in the C++0x standart, but I'd like not to use any C++0x features. ...

Callback, specified in QueueUserAPC , does not get called

In my code, I use QueueUserAPC to interrupt the main thread from his current work in order to invoke some callback first before going back to his previous work. std::string buffer; std::tr1::shared_ptr<void> hMainThread; VOID CALLBACK myCallback (ULONG_PTR dwParam) { FILE * f = fopen("somefile", "a"); fprintf(f, "CALLBACK WAS IN...

A way to do c++ "typedef struct foo foo;" for c

Going by gcc version 4.4.2, it appears that saying typedef struct foo foo; // more code here - like function declarations taking/returning foo* // then, in its own source file: typedef struct foo { int bar; } foo; is legal in C++ but not in C. Of course I have a body of code that compiles fine in C++ by using the foo type but it ...

WINAPI: Look at messages from other process

Hi, I'm quite new to the Windows API and would like to know how to peek at messages another process receives. As an example, I would like to get the HWND of, say, notepad and peek at all messages that are sent to this window. I code in C/C++. Thank you ...

How can I use boost::mpl::fold with a boost::fusion::map?

Hi. When I try to compile this: #include <boost/fusion/container/map.hpp> #include <boost/mpl/fold.hpp> int main(int argc, char** argv) { typedef boost::fusion::map < boost::fusion::pair<int, const char*>, boost::fusion::pair<long, char> > FuMap; FuMap fuMap("hello", 'w'); unsigned val = boost::mpl...