c++

A single MFC/Win32 control seems to be making my whole desktop repaint

I have a custom control, which owns an edit box and moves it around, etc. The edit-box is typically modified with a wodge of code like this: edit.MoveWindow( &rc ); edit.SetWindowText( text ); edit.SetLimitText( N ); edit.ShowWindow(SW_SHOW); edit.SetFocus(); edit.SetSel(0, CB_ERR); RECT rc is in coordinates local to the custom contro...

Is no parentheses on a C++ constructor with no arguments a language standard?

I was compiling a C++ program in Cygwin using g++ and I had a class whose constructor had no arguments. I had the lines: MyClass myObj(); myObj.function1(); And when trying to compile it, I got the message: error: request for member 'function1' in 'myObj', which is of non-class type 'MyClass ()()' After a little research, I found th...

Portable c++ atomic swap (Windows - GNU/Linux - MacOSX)

Hi, Is there free a portable (Windows, GNU/Linux & MacOSX) library providing a lock-free atomic swap function? If not, how would it be implemented for each of these platforms? (x86 with VC++ or g++) Thanks ...

How to format date in SQLite according to current locale format settings?

I need to match on a date using the LIKE operator. The date should be in current user's local format, not in the general format. So I use the strftime function like this: WHERE strftime('%d.%m.%Y %H:%M', createdDate, 'localtime') LIKE '%{searchTerm}%' Unfortunately this works only for fixed format '%d.%m.%Y %H:%M'. But I want to use ...

Problem with boost::variant, linker giving a segfault

I have a boost variant with 7 types in it. When I try to use the last two types, the linker segfaults. I am using g++ (gcc version 3.3.3 on SuSE Linux) on a 64 bit linux machine and the error that I get is collect2: ld terminated with signal 11 [Segmentation fault] It doesnt matter what order I put the types in, the last two will cau...

C(++) malloc confusion

I'm just not getting any further with allocating memory for arrays in C and mainly C++. I've looked for examples but there aren't any useful ones for me out there, at least it seems so. So if I have a typedef here like this: typedef struct { int x; int y; } Coordinate; Coordinate* myList; And I have an array of the type Coordinate t...

Qt::Tool window diasappears when application become inactive.

I have problem with keeping Qt::Tool window visible when the application becomes inactive. The application is running and there are 2 windows opened - main and additional with Qt::Tool flag set. When I open/switch to other app e.g Konosole the main window remains visible but second disappears - so if I want to e.g. rewrite some data from...

Dynamic array of COM objects

I have an ATL COM object which needs to expose a collection of other COM objects, so clients can find out how many objects are in the collection (via a simple Count property which I can provide) and access the objects using its index. This collection of objects is dynamic - the count is not fixed - and I don't know how many there will b...

How to select against which version of the Visual C++ libraries the application is compiled?

I'm using Visual Studio 2008 for C++. When compiling, Visual Studio compiles against the header files of the VC 9.0 libraries. However, there are different versions of this library available: v9.0.21022.8 (= RTM) v9.0.30729.17 (= SP1) v9.0.30729.4148 (= SP1 with security update) I'd like to know whether it is possible to tell Visual...

DsMakeSpn Always Fails on Windows Server 2008

What could be the reason for consistent failure when calling DsMakeSpn? The error code is 87. Thanks in advance!! ...

Using SQLite with QT

I am thinking of using SQLite as a backend DB for a C++ applicatiojn I am writing. I have read the relevant docs on both teh trolltech site and sqlite, but the information seems a little disjointed, there is no simple snippet that shows a complete CRUD example. I want to write a set of helper functions to allow me to execute CRUD action...

Deleting a regular expression match

I have a program that I need to be able to search a file with regex epressions and delete what regex has found. Here is the code I have been working on: #include <boost/regex.hpp> #include <iostream> #include <string> #include <fstream> #include <sstream> #include "time.h" using namespace std; class application{ private: //Variables ...

Linking additional dependencies with XCode

I'm trying to compile a game I made with the Allegro library. The library has .a files which I need to tell XCode to use because right now my code has no errors but it as unreferenced function errors which means it needs the .a files to do the static linking. How do I provide these to XCode? (sort of like the XCode equivalent of MSVC's ...

How to use C macro's (#define) to alter calls but not prototypes

In our application (older parts) we alter calls to malloc (and realloc) and free so our own implementations are called instead of the standard runtime ones, e.g. #define malloc(s) OurMalloc(s) #define free(p) OurFree(p) This works quite good (for newer C++ code we simply implement global new and delete operators, so the C++ solution...

c++ InterlockedExchangePointer and pointer alignment

The documentation for the InterlockedExchangePointer Function states: On a 64-bit system, the parameters are 64 bits and the Target parameter must be aligned on 64-bit boundaries; otherwise, the function will behave unpredictably. On a 32-bit system, the parameters are 32 bits and the Target parameter must be aligned on 32-bit bounda...

C++ malloc - dynamic array

Assuming that I have a program that has an array of unknown lenght that consists of Customers. Here, a customer struct: struct Customer { char* lastname; char* firstname; int money; }; And here - an array: Customer* CustomerDB; Okay. But the thing is that I want to add and remove customers dynamically during runtime. I don't wa...

Comparing address of std::endl

I am inspecting a piece of existing code and found out it behaves differently when compiled with Visual C++ 9 and MinGW: inline LogMsg& LogMsg::operator<<(std::ostream& (*p_manip)(std::ostream&) ) { if ( p_manip == static_cast< std::ostream& (*)(std::ostream&) > ( &std::endl<char, std::char_traits<char> >) ) { msg(m_outp...

Why does C++ code missing a formal argument name in a function definition compile without warnings?

While getting started with some VS2005-generated MFC code, I noticed it overrode a method with something like this: void OnDraw(CDC* /*pDC*/) { ... // TODO: Add your code here } So of course, as soon as I added something I realized I needed to un-comment the pDC formal argument in order to compile, but I'm confused as to how/w...

Random Complete System Unresponsiveness Running Mathematical Functions

I have a program that loads a file (anywhere from 10MB to 5GB) a chunk at a time (ReadFile), and for each chunk performs a set of mathematical operations (basically calculates the hash). After calculating the hash, it stores info about the chunk in an STL map (basically <chunkID, hash>) and then writes the chunk itself to another file ...

What is the preference of function/method/template name resolving in C++?

How does the C++ compiler decide which function/method to call if there are multiple possibilities? In my specific case I have the standard free function of the C++ Run time and I also have a templated free variant, like this: // The definitions of the C++ Run Time Library (from memory.h) extern malloc(size_t s); extern void free(void *...