c++

How to print additional information when assert fails?

Often one wants to print out additional information if an assert fails. A way to do that is this: assert(vec.size() > i || !(std::cerr << "False: " << vec.size() << ">" << i)) This way the actual sizes are printed when the assert fails. But it's ugly, and also it's easy to forget the ! , which will make the assertion condition true...

Which boost libraries are heading for TR2?

If found this quote at boost.org: More Boost libraries are in the pipeline for TR2 It links to the TR2 call from proposals. But I can't seem to find any other information on which boost libraries are headed for TR2. I've seen a draft proposal for Boost.Asio, and I vaguely remember seeing something about Boost.System and Boost.Fil...

Can DDD account for strings?

I am trying to figure out a problem in my c++ code and have DDD to debug with on a Sun machine. I am required to use strings per some standard we have. But whenever DDD encounters a string variable, it always comes up as being empty. I want to remember having the same trouble using CVD before on an SGI. Short of re-writing my code to ...

Convert a Static Library to a Shared Library (create libsome.so from libsome.a): where's my symbols?

the title of this question is an exact dupe, but the answers in that question don't help me. I have a bunch of object files packed in a static library: % g++ -std=c++98 -fpic -g -O1 -c -o foo.o foo.cpp % g++ -std=c++98 -fpic -g -O1 -c -o bar.o bar.cpp % ar -rc libsome.a foo.o bar.o I'd like to generate libsome.so from libsome.a inste...

Why does GetLastError() return different codes during debug vs "normal" execution?

try { pConnect = sess->GetFtpConnection(ftpArgs.host, ftpArgs.userName, ftpArgs.password, port, FALSE ); } catch (CInternetException* pEx) { loginErrCode = GetLastError(); printf("loginErrCode: %d\n", loginErrCode); if(loginErrCode == 12013) { printf("Incorrect user name!\n"); exit(0); } ...

Simple proxy program with BOOST

Hi all... I'm trying to do a very simple program. It's actually a proxy, that I need to connect to it and that proxy fowards the packets to the outter world. I think of making a list of incomming packets, change the incomming port to a new port, forward the packet and wait for a response, and get the port number for the packet from my...

FIFO list (moving elements) [C++]

Good evening, people! I'm trying to solve a rather simple problem, but.. well, it seems that I can't. :) The idea is that I have a FIFO list (FIFO queue) with n elements and it's given a value, k (k < n). My little program has to move the elements to the left with k elements. (e.g. for n=4, k=3, a[]=(1, 2, 3, 4), the result is 4 1 2 3)...

Getting 32 bit words out of 64-bit values in C/C++ and not worrying about endianness...

It's my understanding that in C/C++ bitwise operators are supposed to be endian independent and behave the way you expect. I want to make sure that I'm truly getting the most significant and least significant words out of a 64-bit value and not worry about endianness of the machine. Here's an example: uint64_t temp; uint32_t msw, lsw;...

How to get caption of ListBox control

How can I get the caption of ListBox control. I have handle to Listbox control. I tried with following , but it returned empty string SendMessage(hListBox,WM_GETTEXT,MAX_PATH,(LPARAM)wszCaption); Any suggestion of how to get the caption associated with ListBox. ...

FindWindowEx not able to find window handle.

I am trying to find the handle to a dialog as soon as it opens. Now as soon as dialog is opened I try to call FindWindowEx for that dialog in a separate thread but it returns NULL. I then put some sleep before calling FindWindowEx. It works some time after putting sleep. It looks like FindWindowEx is getting called before even dialo...

How to compare two objects (the calling object and the parameter) in a class?

Hello, I am writing a "Date" class for an assignment and I am having trouble doing one the of the functions. This is the header file for the class. class Date { public: Date(); // Constructor without parameters Date(int m, int d, int y); // Constructor with parameters. // accessors int GetMonth(); ...

How to modify the keyboard input in QT?

Hi, The following feature needs to be implemented to our existing QT & C++ application. We have to expand the user typed abbreviations into pre-defined words(s). The functionality we need to implement is something similar to text expander. Say if a user typed "FL", this needs to be replaced to "Florida" after immediately. I was able t...

What good are thread affinity mask changes for the current thread?

Hello, I'm writing a game engine and I need a way to get a precise and accurate "deltatime" value from which to derive the current FPS for debug and also to limit the framerate (this is important for our project). Doing a bit of research, I found out one of the best ways to do this is to use WinAPI's QueryPerformanceCounter function. G...

Should I cache the hash code of an STL string used as a hash key?

I've doing some performance analysis on the software I develop, and I've found that lookups on a global dictionary of URL's takes about 10% of the application's "load" phase time. The dictionary is implemented as a C++ STL std::map, which has O(lg n) lookups. I'm going to move it to a hash_map, which has roughly fixed time lookups. Th...

Error with using a function as a non-type template parameter

I have this template : template <class SourceFormat, class DestFormat, void (*convert)(DestFormat, SourceFormat)> static void _draw(...); And these functions : template <class Class1, class Class2> inline static void convertNone(Class1& dest, Class2& source) { dest = source; }; inline static void c...

A destructor - should I use delete or delete[]?

I am writing a template class that takes as an input a pointer and stores it. The pointer is meant to point to an object allocated by another class, and handed to the this containing class. Now I want to create a destructor for this container. How should I free the memory pointed to by this pointer? I have no way of knowing a priori wh...

Linked List explanation required

I need to understand how a linked list works in this C++ code. I got it from my textbook. Could someone explain in detail what exactly is going on here? /*The Node Class*/ class Node{ private: int object; Node *nextNode; public: int get() { return object; } ...

How to copy by value into a container class?

I am writing a sparse matrix class. I need to have a node class, which will be a template for its contents. My issue in writing this class is: How do I store the contents? I want to store the contents by value. If I stored it by pointer and it should be destroyed, then I'd have trouble. How can I safely perform a copy in the setConte...

Visual Build professional compile errors?

I am using visual build professional and one of the steps is a 'Make VS 2003' (c++ project). However, every time I get the following error: fatal error C1033: cannot open program database '' If I compile the project myself in visual studios it works fine. Anyone know why this would be, or how I can fix it? ...

Detect Window Move in Property Page (win32)

I implemented a wizard using property sheet. One one page I display tooltip if user enters something invalid. It is a tracking tooltip so I have to manually turn it on and off. Now I want to move the tooltip when the wizard page moves. It seems that only the property sheet window receives WM_MOVE event from Windows. The page does not. I...