c++

Getting Loki Singleton to work in DLLs in VS 2008 C++

I'm pretty sure this problem isn't new, and pretty sure it's hard to solve. Hopefully I'm wrong about the latter. I'm trying to use the Loki::Singleton from Modern C++ Design in a program of mine. However, I can't seem to get it to work across DLLs. I think I know why this is happening: the templated code gets instantiated in every ...

STL vector allocations

I was wondering why the vector templates perform two allocations, when only one seems to be necessary. For example this: #include <vector> #include <iostream> class A { public: A(const A &a) { std::cout << "Calling copy constructor " << this << " " << &a << "\n"; } A() { std::cout ...

Qt - creating QPainter

Hello, i'm trying to rewrite method paintEvent in my programm and change it. void MainWindow::paintEvent(QPaintEvent *event) { QRegion reg = this->bgPixmapHandle->rect(); QPainter painter(this); painter.setClipRegion(reg); painter.drawImage(bgPixmapHandle->rect(), bgPixmapHandle); painter.end(); } Here i try to ch...

C++ Singleton design pattern.

Recently I've bumped into realization/implementation of Singleton design pattern for C++. It has looked in the following way (I have adopted it from real life example): // a lot of methods is omitted here class Singleton { public: static Singleton* getInstance( ); ~Singleton( ); private: Singleton( ); s...

Boost library setup for Codeblocks

How to use boost libraries with Codeblocks(Windows) ? What i need to do after downloading the library from boost site ? Any idea, suggestions, pointers ? ...

XXX.exe is not a valid Win32 application

Configuration: Windows server 2008 x64. Software is cross platform c++ 64bit. The previous installer defaulted to asking the user to install to c:\Program Files (x86)\company\version For the last release I changed the installer using a path override to install to c:\Program Files\company\version The guys who does testing for us sa...

interoperatability Cpluspluss_CLI_ManagedArray <--> Array

Hello There, How can i convert interoperatability between a c++/CLI Array and a native c++ array AND VICE VERSA. array^ Cpluspluss_CLI_ManagedArray; unsigned char* UnmanagedArray; I found the System::Runtime::InteropServices::Marshal; (IntPtr) there is so much of information for a first timer like me (to CLI) So I'm not sure about wh...

How to avoid explicitly calling a constructor when passing temporary object by reference in C++?

Let's say I have a class: class String { public: String(char *str); }; And two functions: void DoSomethingByVal(String Str); void DoSomethingByRef(String &Str); If I call DoSomethingByVal like this: DoSomethingByVal("My string"); the compiler figures out that it should create a temporary String object and call the char* con...

COM event with binary data in arguments

I am trying to develop a COM object using C++ and ATL to be used by both C++ and C# Windows Mobile clients. The COM object wraps up all of the logic to connect to our server and send/receive data using our proprietary protocol. I am having some difficulty coming up with an OnReceive event that works correctly with C# and C++. I have d...

Boost.Python and Python exceptions.

Hello! How can I make boost.python code python exceptions aware? For example, int test_for(){ for(;;){ } return 0; } doesn't interrupt on Ctrl-C, if I export it to python. I think other exceptions won't work this way to. This is a toy example. My real problem is that I have a C function that may take hours to compute. And I...

What does this mean?

This: typedef HRESULT (*PFN_HANDLE)(ClassName&); It's used like this: DWORD ClassName::Wait(PFN_HANDLE pfnh_foo) { while (!done) { waitCode = WaitForMultipleObjects(paramA, paramB, paramC, paramD) if (waitCode == WAIT_OBJECT_0) { pfnh_foo(*this); } else done; } return waitCode; } It appears th...

how to merge two BST's efficiently?

how to merge two binary search trees maintaining the prop of BST...naive way of doing it is take each element from a tree and insert it into the other... Complexity of this method being O(n1 * log(n2)).. where n1 is the no of nodes of the tree(say T1) which we have splitted and n2 is the number of nodes of the other tree(say T2)... ...

On closing a Qt 4.5 application, Visual Studio reports that it has detected memory leaks

I am building a Qt 4.5 application on Windows using Visual Studio 2008. Whenever I run my application in Debug mode and then close it, Visual Studio prints the following to the output pane: Detected memory leaks! Dumping objects -> {696512} normal block at 0x01981AB0, 24 bytes long. Data: < > 00 CD CD CD 00 00 00...

what does this C++ macro do ?

This is for MSVC #define Get64B(hi, lo) ((((__int64)(hi)) << 32) | (unsigned int)(lo)) Specifically, what is the role of the 'operator <<' ? Thanks for your help ...

Win32 Read/Write Lock Using Only Critical Sections

I have to implement a read/write lock in C++ using the Win32 api as part of a project at work. All of the existing solutions use kernel objects (semaphores and mutexes) that require a context switch during execution. This is far too slow for my application. I would like implement one using only critical sections, if possible. The loc...

What are the Disadvantages of Early Binding??

http://stackoverflow.com/questions/367411/early-binding-vs-late-binding-what-are-the-comparative-benefits-and-disadvantag........ i didn't find any thing which can help me.. ...

Interprocess communication on windows

I have a TCL script running on windows. I need to communicate to a old vc++ 6 app running in a different process. I need to have 2 way communication. In Linux I would use dbus, but what IPC strategy should I use for windows? ...

Extracting data from jpeg files

Hi, I want to extract some kind of bmp/rgb data from jpeg files. I had a look at libjpeg, but there seemed not to be any good documentation available. So my questions are: Where is documentation on libjpeg? Can you suggest other c-based jpeg-decompression libraries? thanks in regard ps: I am using GNU/Linux, and c/c++ ...

Linking with both static and dynamic libraries in MSVC

I am working on a c++ project that links to a static library. However, I want to use intel's TBB, which is only available as a dynamic library. I tried to set this up in visual studio but I can't get it to work. Does anyone have detailed directions to do this if it is possible? ...

Is it possible to strip debug information from a COFF library file (.lib)?

I am linking with a number of 3rd party .lib files, and I get a large number of LNK4099 warnings at link time. It appears that this warning message cannot be supressed, so I believe that if I remove all debug information from the .lib files, the warning will not be shown. Is there a way to remove the debug information? These are librarie...