c++

c++ enum to unsigned int comparison

I found this in the code I'm working on at the moment and thought it was the cause of some problems I'm having. In a header somewhere: enum SpecificIndexes{ //snip INVALID_INDEX = -1 }; Then later - initialization: nextIndex = INVALID_INDEX; and use if(nextIndex != INVALID_INDEX) { //do stuff } Debugging the code, t...

How can I preserve UTC in a CDateTimeCtrl?

My MFC application has a dialogue with a date picker. When I initialise this dialogue, I need to call CDateTimeCtrl::SetTime() and I'm trying to decide what argument to give it. I have an array of integers representing a year, month, day, hour and minute in UTC. Here's the important bit: the date picker must display the time in UTC, n...

C++ Visual Studio Runtime Error

Can anyone explain to me what this means? "Run-Time Check Failure #0 - The value of ESP was not properly saved across a function call. This is usually a result of calling a function declared with one calling convention with a function pointer declared with a different calling convention." ...

Printing the stack trace in C++ (MSVC)?

In my C++ application (developed with Visual Studio 2003) and Qt4, I'd like to print the stack trace from a specific line of code, either to the console output or into a file. What would it take ? Is Qt of any help to do this ? ...

Vector iterator not dereferencable

Hi, I have an abstract base class called Shape from which both Circle and Rectangle are derived, but when I execute the following code in VS 2005 I get the error Debug assertion failed. At the same time I have not overloaded == operator in any class Expression:Vector iterator not dereferencable, what is the reason for this. vector<S...

Write large file

I try to write to a large file, but it seems like it does not work for files larger than 2GB. I have tried with boost::iostreams::file_sink. Is this just a limit with the boost stream? Is there some other way I can write a large file on Win64 and win32? ...

Where can i get c++ standard manual?

Where can i get c++ standard manual? Is that free? DUPLICATE: http://stackoverflow.com/questions/204841/where-can-i-look-at-the-c-standard ...

How do you build the x64 Boost libraries on Windows?

I've built the x86 Boost libraries many times, but I can't seem to build x64 libraries. I start the "Visual Studio 2005 x64 Cross Tools Command Prompt" and run my usual build: bjam --toolset=msvc --build-type=complete --build-dir=c:\build install But it still produces x86 .lib files (I verified this with dumpbin /headers). What am I d...

How do I change the ACLs on a registry key? (C++)

I need to delete a regsitry key. It has a deny ACL on Set Value (I need this permission to delete it). How do I change the ACLs in C++? ...

Firefox plugin crashes in Chrome

From what I gather, Google Chrome can run browser plugins written using NPAPI. I've written one that does its job just fine in Firefox, but makes Chrome crash and burn as soon as you embed it on a page. I don't even have to call any of my methods, embedding is enough to cause a crash. How do I debug this? I tried attaching the debugg...

How can one inspect a vtable in Visual C++?

Suppose one had inherited a complex codebase (in Visual C++, assume 2003 or perhaps later) with a large and complex inheritance graph. Suppose it's deep, and there's lots of virtual functions and possibly even multiple inheritance as well. (Yes, a bit of a maintenance nightmare). Any attempt to refactor this class hierarchy into somethin...

How much null checking is enough?

What are some guidelines for when it is not necessary to check for a null? A lot of the inherited code I've been working on as of late has null-checks ad nauseam. Null checks on trivial functions, null checks on API calls that state non-null returns, etc. In some cases, the null-checks are reasonable, but in many places a null is not a ...

Reading a file of mixed data into a C++ string

I need to use C++ to read in text with spaces, followed by a numeric value. For example, data that looks like: text1 1.0 text two 2.1 text2 again 3.1 can't be read in with 2 "infile >>" statements. I'm not having any luck with getline either. I ultimately want to populate a struct with these 2 data elements. Any ideas? ...

Why does Visual C++ not hit a breakpoint in, or step through a specific function?

I have the following: classA::FuncA() { ... code FuncB(); ... code } classA::FuncB(const char *pText) { SelectObject(m_hDC, GetStockObject ( SYSTEM_FONT)); wglUseFontBitmaps(m_hDC, 0, 255, 1000); glListBase(1000); glCallLists(static_cast<GLsizei>(strlen(pText)), GL_UNSIGNED_BYTE, pText); } I can hit breakpoi...

How to make the wxWidgets wxCmdLineParser object print its messages to the console?

Background I'm using wxWidgets 2.8.7 to make a console application that takes command line parameters. To parse these parameters, I'm using the wxCmdLineParser class. When an invalid parameter is provided to the application, the desired behavior - and the one described by the wxCmdLineParser documentation - is to print the usage message...

CRC32 C or C++ implementation

I'm looking for an implementation of CRC32 in C or C++ that is explicitly licensed as being free or public domain. The implementation here seems nice, but the only thing it says about the license is "source code", which isn't good enough. I'd prefer non LGPL so I don't have to fool around with a DLL (my app is closed source). I saw th...

Store 2D points for quick retrieval of those inside a rectangle

I have a large number of 2D points and I want to quickly get those that lie in a certain rectangle. Let's say a '.' is any point and 'X' is a point I want to find inside a rectangle which has 'T' as TopLeft and 'B' as BottomRight points: . . . . . . . T-----+ . . | X X | . . +-----B . . . . . . . I have tried a std::set with a sort fu...

what's the easiest way to generate xml in c++?

I've used boost serialization but this doesn't appear to allow me to generate xml that conforms to a particular schema -- it seems it's purpose was to just to persist a class's state. Platform: linux What do you guys use to generate NOT parse xml? So far I'm going down Foredecker's route of just generating it myself -- it's not a larg...

Implementing threads using C++

I have an API call in my application where I am checking the time taken for a single call. I have put this in a FOR loop and using 10000 calls to get the average times of all calls. Now the issue which came up was that the actual application using the API, is multi-threaded. If I wish to make my application also do the same, how would I ...

C++ format macro / inline ostringstream

I'm trying to write a macro that would allow me to do something like: FORMAT(a << "b" << c << d), and the result would be a string -- the same as creating an ostringstream, inserting a...d, and returning .str(). Something like: string f(){ ostringstream o; o << a << "b" << c << d; return o.str() } Essentially, FORMAT(a << "b" ...