c++

Missing/desired features in Visual C++

I can't find another topic where this has already been asked, so I'm starting one... if there is one, feel free to link it and close this. What feature do you feel is most missing from Visual C++? Microsoft has been adding nice features for C#/VB.NET development for the last couple versions, but C++ has felt a bit neglected. I don't ha...

Determine if IP is blocked

Does anyone know if it is possible to reliably determine (programattically C/C++...) whether or not a firewall or IP filtering software is installed on a Windows PC? I need to detect whether a certain server IP is being blocked in my client software by the host OS. I don't need to worry about external hardware firewals in this situatio...

wglCreateContext in C# failing but not in managed C++

I'm trying to use opengl in C#. I have following code which fails with error 2000 ERROR_INVALID_PIXEL_FORMAT First definitions: [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true, ExactSpelling = true)] public static extern IntPtr GetDC(IntPtr hWnd); [StructLayout(LayoutKind.Sequential)] public struct PIXELFORMATD...

Compiling a QT program in Windows XP with MinGW's g++

I have a stub Qt application and I keep getting compiler errors #include <QApplication> int main(int argc, char *argv[]) { return 0; } I used qmake -project and qmake commands and as far as I can tell they did their job correctly. When I subsequently call make at the command line I get the following error: g++ -c -O2 -frtti ...

Best way to detect integer overflow in C/C++

I was writing a program in C++ to find all solutions of a^b = c (a to the power of b), where a, b and c together use all the digits 0-9 exactly once. The program looped over values of a and b, and ran a digit-counting routine each time on a, b and a^b to check if the digits condition was satisfied. However, spurious solutions can be gen...

C++: What's the simplest way to read and write BMP files using C++ on Windows?

I would like to load a BMP file, do some operations on it in memory, and output a new BMP file using C++ on Windows (Win32 native). I am aware of ImageMagick and it's C++ binding Magick++, but I think it's an overkill for this project since I am currently not interested in other file formats or platforms. What would be the simplest way ...

Using C++ library in C code

I have a C++ library that provides various classes for managing data. I have the source code for the library. I want to extend the C++ API to support C function calls so that the library can be used with C code and C++ code at the same time. I'm using GNU tool chain (gcc, glibc, etc), so language and architecture support are not an is...

How would you go about implementing the game reversi? (othello)

I have been thinking about starting a side project at home to exercise my brain a bit. Reversi looks like a simply game, where mobility has a profound effect on game play. It is at least a step up from tic tac toe. This would be a single player against an AI of some sort. I am thinking to try this in C++ on a PC. What issues am I l...

How should C bitflag enumerations be translated into C++?

C++ is mostly a superset of C, but not always. In particular, while enumeration values in both C and C++ implicitly convert into int, the reverse isn't true: only in C do ints convert back into enumeration values. Thus, bitflags defined via enumeration declarations don't work correctly. Hence, this is OK in C, but not in C++: typedef en...

Converting C source to C++

How would you go about converting a reasonably large (>300K), fairly mature C codebase to C++? The kind of C I have in mind is split into files roughly corresponding to modules (i.e. less granular than a typical OO class-based decomposition), using internal linkage in lieu private functions and data, and external linkage for public func...

IDL declaration (in C++) for a function that will take a C-style array from C#

I am working with an existing code base made up of some COM interfaces written in C++ with a C# front end. There is some new functionality that needs to be added, so I'm having to modify the COM portions. In one particular case, I need to pass an array (allocated from C#) to the component to be filled. What I would like to do is to be ...

How to detect possible / potential stack overflow problems in a c / c++ program?

Is there a standard way to see how much stack space your app has and what the highest watermark for stack usage is during a run? Also in the dreaded case of actual overflow what happens? Does it crash, trigger an exception or signal? Is there a standard or is it different on all systems and compilers? I'm looking specifically for Win...

Setting Background Color CMDIFrameWnd

Is there a way to change the color of the background for a MDIParent windows in MFC (2005)? I have tried intercepting ON_WM_CTLCOLOR AND ON_WM_ERASEBKGND but neither work. OnEraseBkgnd does work, but then it gets overwritten by the standard WM_CTL color. Cheers ...

What is the equivalent of Thread.SetApartmentState in C++?

In C# there is a method SetApartmentState in the class Thread. How do I do the same thing in C++? ...

With scons, how do you link to prebuilt libraries?

I recently started using scons to build several small cross-platform projects. One of these projects needs to link against pre-built static libraries... how is this done? In make, I'd just append "link /LIBPATH:wherever libstxxl.lib" on windows, and "stxxl.a" on unix. ...

Are C++ meta-templates required knowledge for programmers?

In my experience Meta-templates are really fun (when your compilers are compliant), and can give good performance boosts, and luckily I'm surrounded by seasoned C++ programmers that also grok meta-templates, however occasionally a new developer arrives and can't make heads or tails of some of the meta-template tricks we use (mostly Andre...

How do you convert a C++ string to an int?

How do you convert a C++ string to an int? Assume you are expecting the string to have actual numbers in it ("1", "345", "38944", for example). Also, let's assume you don't have boost, and you really want to do it the C++ way, not the crufty old C way. ...

UTF usage in C++ code

What is the difference between UTF and UCS. What are the best ways to represent not European character sets (using UTF) in C++ strings. I would like to know your recommendations for: Internal representation inside the code For string manipulation at run-time For using the string for display purposes. Best storage representation (i.e...

Where can I learn more about C++0x?

I would like to learn more about C++0x. What are some good references and resources? Has anyone written a good book on the subject yet? ...

Trapping messages in MFC - Whats the difference?

Hi all, I was just wondering what (if any) the difference was between the following two message traps in MFC for the function, OnSize(..). 1 - Via Message map: BEGIN_MESSAGE_MAP(CClassWnd, CBaseClassWnd) ... ON_WM_SIZE() .. END_MESSAGE_MAP() 2 - Via afx_message: afx_msg type OnSize(...); They seem to be used interchangeably, ...