c++

Is this a bug in gdb ? Does someone know how to fix it ?

I am currently running gdb version 6.7.1 on Ubuntu Linux, and working in a C++ project. Surprisingly I was trying to debug a constructor and I have found that local variables declared within the scope of the constructor are not followed or noticed by gdb. Is this a bug ? Thanks for any information .. ...

Infinite loops - top or bottom?

In the spirit of questions like Do your loops test at the top or bottom?: Which style do you use for an infinite loop, and why? while (true) { } do { } while (true); for (;;) { } label: ... goto label; ...

Capturing R6025 pure virtual call

I currently capture MiniDumps of unhandled exceptions using SetUnhandledExceptionFilter however at times I am getting "R6025: pure virtual function". I understand how a pure virtual function call happens I am just wondering if it is possible to capture them so I can create a MiniDump at that point. ...

Why use infinite loops?

Another poster asked about preferred syntax for infinite loops. A follow-up question: Why do you use infinite loops in your code? I typically see a construct like this: for (;;) { int scoped_variable = getSomeValue(); if (scoped_variable == some_value) { break; } } Which lets you get around not being able to see the value o...

Create an Application without a Window

How would you program a C/C++ application that could run without opening a window or console? ...

Is there a way to check if an istream was opened in binary mode?

I'm using an istream which could be stringstream, ifstream or a user-defined stream type and I need to know if, in the case of an ifstream, it was not opened in binary mode (so I can throw an exception). I have tried the following method: if ((_is.flags() & ios::binary) == 0) throw exception(...) but no exception is ever thrown. T...

Why do people use __(double underscore) so much in C++

I was having a look through some open source C++ code and notice a lot of double under scores where used in the code, mainly at the start of variable names. return __CYGWIN__; Just wondering is there a reason for this, or is it just some people code styles? I would think that I makes it hard to read. ...

Constant value in conditional expression

In a coding style question about infinite loops, some people mentioned they prefer the for(;;) style because the while(true) style gives warning messages on MSVC about a conditional expression being constant. This surprised me greatly, since the use of constant values in conditional expressions is a useful way of avoiding #ifdef hell. F...

How does "Edit and continue" work in Visual Studio?

I have always found this to be a very useful feature in Visual Studio. For those who don't know about it, it allows you to edit code while you are debugging a running process, re-compile the code while the binary is still running and continue using the application seamlessly with the new code, without the need to restart it. How is thi...

boost lambda or phoenix problem: using std::for_each to operate on each element of a container

I ran into a problem while cleaning up some old code. This is the function: uint32_t ADT::get_connectivity_data( std::vector< std::vector<uint8_t> > &output ) { output.resize(chunks.size()); for(chunk_vec_t::iterator it = chunks.begin(); it < chunks.end(); ++it) { uint32_t success = (*it)->get_connectivity_data(output[it-chunks.beg...

Thread local storage with __declspec(thread) fails in C++/CLI

I'm working on a project where we mix .NET code and native C++ code via a C++/CLI layer. In this solution I want to use Thread Local Storage via the __declspec(thread) declaration: __declspec(thread) int lastId = 0; However, at the first access of the variable, I get a NullReferenceException. To be more precise, the declaration is don...

Private and Protected Members : C++

Can someone enlighten me as to the difference between private and protected members in classes? I understand from best practice conventions that variables and functions which are not called outside the class should be made private - but looking at my MFC project, MFC seems to favour protected. Whats the difference and which should I use...

How can I stream video from my application to the web?

I have an application that grabs video from multiple webcams, does some image processing, and displays the result on the screen. I'd like to be able to stream the video output on to the web - preferably to some kind of distribution service rather than connecting to clients directly myself. So my questions are: Do such streaming dist...

How to generate empty definitions given a header file

I have a 3rd-party library which for various reasons I don't wish to link against yet. I don't want to butcher my code though to remove all reference to its API, so I'd like to generate a dummy implementation of it. Is there any tool I can use which spits out empty definitions of classes given their header files? It's fine to return nu...

Best XML serialization library for a MFC C++ app

I have an application, written in C++ using MFC and Stingray libraries. The application works with a wide variety of large data types, which are all currently serialized based on MFC Document/View serialize derived functionality. I have also added options for XML serialization based on the Stingray libraries, which implements DOM via t...

Convert a number to a string with specified length in C++

I have some numbers of different length (like 1, 999, 76492, so on) and I want to convert them all to strings with a common length (for example, if the length is 6, then those strings will be: '000001', '000999', '076492'). In other words, I need to add correct amount of leading zeros to the number. int n = 999; string str = some_func...

Export all symbols when creating a DLL

With VS2005, I want to create a DLL and automatically export all symbols without adding __declspec(dllexport) everywhere and without hand-creating .def files. Is threre a way to do this? ...

Embed image in code, without using resource section or external images

I'm looking for a way to embed an image in a library (Windows-only). I don't want to go the 'traditional' way of putting it in the resources (because of special circumstances that make it not so convenient to mess around with the resource handle. Ideally, there would be something like xpm files: a 'text' representation of an image that ...

C++0X when?

What are the latest news about C++0X? (or should I say C++1X) Any release date decided yet? ...

True color CImageList

How do I load a true color image into a CImageList? Right now I have mImageList.Create(IDB_IMGLIST_BGTASK, 16, 1, RGB(255,0,255)); Where IDB_IMGLIST_BGTASK is a 64x16 True color image. The ClistCtrl I am using it in shows 16 bpp color. I don't see a Create overload that allows me to specify both the bpp and the resource to load fro...