c++

C++ Separate Compilers for classes (vtables)?

I was wondering what the consequences are for compiling a class A with one compiler that doesn't allow multiple inheritance, and compiling a class B that does support it (and class B derived from class A). I don't really understand the linking process...would it be possible to use both together? What disadvantages exist for using separa...

Qt Custom Window

Hi, Pardon me, I am a newbie :) Is it possible in Qt to create a custom window without borders but still draggable without holding down the Alt Key? I created a borderless window but in order to be able to drag it (on Linux) you have to hold down the alt key. I was planning to create a window with rounded corners. Any one have any ide...

C++ array with value semantics and no allocator shenanigans?

I'm looking for a C++ container that's a cross between boost::array, boost::scoped_array and std::vector. I want an array that's dynamically allocated via new[] (no custom allocators), contained in a type that has a meaningful copy-constructor. boost::array is fixed-size, and although I don't need to resize anything, I don't know the s...

Setting the version number in an NCBI c++ toolkit app

How can I set the version number in a NCBI C++ Toolkit Application? I mean the version number which is displayed when I start my program with the parameter -version. I read through the docs, but have not found it yet. (I know this is a highly specific question, but I figured it was worth a try) ...

Patterns for making c++ code easy to test

Should you design your code to make testing easier? And if so how to design c++ code so that it is easy to test. How do you apply dependency-injection in c++? Should I implement the classes using a pure interface class as the base in order to simplify the creation of fake test objects? That would force me into making a lot of virtual...

istream get method behavior

I read istream::get and a doubt still hangs. Let's say my delimiter is actually the NULL '\0' character, what happens in this case? From what I read: If the delimiting character is found, it is not extracted from the input sequence and remains as the next character to be extracted. Use getline if you want this character to be extracte...

MSDN RPC marshal document wrong?

Hello everyone, I am using VSTS 2008 + Native C++ to develop RPC programs (both client and server). I am reading MSDN document for marshalling (The wire_marshal Attribute). I think this sentence is wrong: "For an [out]-only parameter, the server transmits to the client. The server needs the <type>_UserSize and <type>_UserMarsh...

How to initialize a shared library on Linux

Hi there, I am developing a shared library using c++ under Linux. I would like to user log4cxx for logging purposes. However, I'm not sure how to initialize this. For log4cxx I need to create a logger object. How can I make sure this object is created when my library is loaded? I suspect that it will be easiest to create the logger obj...

How do I create a native application using Visual C++ 2008?

I am getting started in C++. How can I setup Visual Studio 2008 to create native (not managed) code? ...

is DISPID_VALUE reliable for invokes on IDispatchs from scripts?

Continuing from this question, i am confused whether DISPID_VALUE on IDispatch::Invoke() for script functions and properties (JavaScript in my case) can be considered standard and reliable for invoking the actual function that is represented by the IDispatch? If yes, is that mentioned anywhere in MSDN? Please note that the question is ...

Inheriting friendship in C++?

Since class friendship is not inherited in C++, what's the best way to "fake" it? I was thinking about exposing the friend class's private interface through protected methods in the to-be-inherited base-class, but that results in having to write (and maintain) the same interface twice. Are there any other ways? ...

How to stop a running thread safely on user request?

I'm in a scenario when I have to terminate a thread while the thread is running according to user action on GUI. I'm using Qt 4.5.2 on Windows. One way to do that is the following: class MyThread : public QThread { QMutex mutex; bool stop; public: MyThread() : stop(false) {} void requestStop() { ...

Boost::typeof compiler problem: mangling typeof, use decltype instead

Hi, short example: #include <boost/typeof/typeof.hpp> #include <boost/proto/core.hpp> using namespace boost; template<class T, class U> BOOST_TYPEOF_TPL(T() + U()) add2(const T& t, const U& u) { return t + u; }; int main(){ typedef BOOST_TYPEOF(add2(2.5, 1.5)) type; // get type -> works BOOST_STATIC_ASSERT((is_same...

c++ problem with build

I have this method declaration in Util.h file 30:string to_string(const bit_vector& v); Util.cc file has the definition string to_string(const bit_vector& v){ string str = ""; for (bit_vector::const_iterator i = v.begin(); i < v.end(); ++i){ if(*i == 1) str += "1"; else str += "0"; } return str; } when I try to bui...

COleDataSource/COleDropTarget cancel drag&drop operation

I have implemented my custom drag&drop by deriving from COleDataSource and COleDropTarget. Everythings work fine but I have an scenario that makes the application crashes. That happens when the dialog where the drag&drop controls are placed is destroyed while the user is in the middle of a drag&drop operation. This is not usual because ...

Vista and out-of-process COM server

I'm having a hell of a time trying to figure out user privilidges and security settings on Vista. The situation is this: I have a 32 bit C++ application that acts as an out-of-process (==standalone exe) COM server. I have several .Net, FoxPro, X++ and C/AL client applications that use this server. They all work on WindowsXP. They often ...

MSBuild / Visual Studio distributed builds

I develop / maintain an app that takes a long time to build (as in, a full build takes in excess of 6 hours!) After having spent most of the day building our app I've started looking into ways of improving build time. The suggesions on this stack overflow question were: Fixing compile warnings Unity builds (for developers) Distribut...

Oracle 7 ProC++ Libraries Help

I am modifying an old DLL which uses Oracle 7 ProC++ precompiled code (SQLLIB18.LIB) and don't have any documentation for this release. No joy back from Oracle either. Does anyone know what the numbers in the following compilation unit data represent? static const short sqlcud0[] = {8,4130,2,0,0,1,189,0,6,49,0,11,11,0,2,7,68,66,95,78,6...

Hooking LoadLibrary API call

I want to load a different version of a DLL than is present in the working directory of the application. For this I need to hook the LoadLibrary call so that when the application makes a call to load the DLL I can substitute it with the newer version of that DLL transparently. I tried using NCodeHook and have the following code in my DLL...

OpenMP: Causes for heap corruption, anyone?

EDIT: I can run the same program twice, simultaneously without any problem - how can I duplicate this with OpenMP or with some other method? This is the basic framework of the problem. //Defined elsewhere class SomeClass { public: void Function() { // Allocate some memory float *Data; Data = new float[1024]; // Dec...