c++

Strange C++ errors with code that has min()/max() calls.

I'm seeing strange errors when my C++ code has min() or max() calls. I'm using Visual C++ compilers. ...

Boost warnings with VC++ 9

When the Boost library/headers is used with VC++ 9 compilers (Visual C++ 2008 Express Edition or Visual Studio 2008), a lot of benign warnings are generated. They are of 2 kinds: Warning about the Wp64 setting. Warning about the compiler version. How can I turn off these warnings? ...

How can an MFC application terminate itself?

What is the proper way for an MFC application to cleanly close itself? ...

Mixed C++/CLI TypeLoadException Internal limitation: too many fields.

On a quest to migrate some new UI into Managed/C# land, I have recently turned on Common Language Runtime Support (/clr) on a large legacy project, which uses MFC in a Shared DLL and relies on about a dozen other projects within our overall solution. This project is the core of our application, and would drive any managed UI code that is...

How do you create a debug only function that takes a variable argument list? Like printf()

I'd like to make a debug logging function with the same parameters as printf. But one that can be removed by the pre-processor during optimized builds. For example: Debug_Print("Warning: value %d > 3!\n", value); I've looked at variadic macros but those aren't available on all platforms. gcc supports them msvc does not. ...

Can placement new for arrays be used in a portable way?

Is it possible to actually make use of placement new in portable code when using it for arrays? It appears that the pointer you get back from new[] is not always the same as the address you pass in (5.3.4, note 12 in the standard seems to confirm that this is correct), but I don't see how you can allocate a buffer for the array to go in...

DLL plugin that creates a parented window doesn't handle messages correctly

I'm creating a plugin framework, where my application loads a series of plugin DLL's, then creates a new window and pass this new window's handle to the plugin. The plugin can, then, use this handle to create their own GUI. Everything seems to be working very well. The only problem is that when I press TAB on a plugin widget (An editbox...

Using Visual Studio to develop for C++ for Unix

Does anyone have battle stories to share trying to use Visual Studio to develop applications for Unix? And I'm not talking using .NET with a Mono or Wine virtual platform running beneath. Our company has about 20 developers all running Windows XP/Vista and developing primarily for Linux & Solaris. Until recently we all logged into a m...

What tools (free or otherwise) do you find useful for developing and debugging C#/C++?

Here are some that I use (all freely available): Hex Editor: Hexplorer http://sourceforge.net/projects/hexplorer/ Debugger: WinDbg http://www.microsoft.com/whdc/resources/downloads.mspx Documentation Compiler: SandCastle http://www.sandcastledocs.com/Wiki%20Pages/Home.aspx Automatic Build: Cruise Control.Net http://ccnet.thoughtworks.co...

Good refactoring support for C++

The Visual Studio refactoring support for C# is quite good nowadays (though not half as good as some Java IDE's I've seen already) but I'm really missing C++ support. I have seen Refactor! and am currently trying it out, but maybe one of you guys know a better tool or plugin? I've been working with Visual Assist X now for a week or tw...

C++ std::tr2 for VS2005

Is Boost the only way for VS2005 users experience TR2? Also is there a idiot proof way of downloading only the TR2 related packages? I was looking at the boost installer provided by BoostPro Consulting. If I select the options for all the threading options with all the packages for MSVC8 it requires 1.1GB. While I am not short of space,...

Test Cases VS ASSERTION statement

In my most C++ project I heavily used ASSERTION statement as following: int doWonderfulThings(const int* fantasticData) { ASSERT(fantasticData); if(!fantasticData) return -1; // ,,, return WOW_VALUE; } But TDD community seems like to enjoy doing something like this: int doMoreWonderfulThings(const int* fantast...

What tools do you use to develop C++ applications on Linux?

I develop C++ applications in a Linux environment. The tools I use every day include Eclipse with the CDT plugin, gdb and valgrind. What tools do other people use? Is there anything out there for Linux that rivals the slickness of Microsoft Visual Studio? ...

Pointer Manipulation Help

Hi everyone, I am trying to build a function in C/c++ to sort an array and replace each value with its "score" or rank. It takes in a double pointer array to an array of ints, and sorts the double pointers based on the dereferenced value of the integers. I have tried quite a few times to make it work, but cant get it down. Once again,...

Most effective way for float and double comparison

What would be the most efficient way to compare two doubles or two floats (single precision)? Simply doing this is not correct: bool CompareDoubles1 (double A, double B) { return A == B; } But something like: bool CompareDoubles2 (double A, double B) { diff = A - B; return (diff < EPSILON) && (-diff > EPSILON); } Seems t...

When should you use 'friend' in C++?

I have been reading through the C++ FAQ and was curious about the friend declaration. I personally have never used it, however I am interested in exploring the language. What is a good example of using friend? Edit: Reading the FAQ a bit longer I like the idea of the << >> operator overloading and adding as a friend of those classes....

C++ Anyway to prevent a method from being over ridden in sub classes?

Is anyone aware of a language feature or technique in C++ to prevent a child class from over riding a particular method in the parent class? class Base { public: bool someGuaranteedResult() { return true; } }; class Child : public Base { public: bool someGuaranteedResult() { return false; /* Haha I broke things! */ } }; Even ...

How do you place a file in recycle bin instead of delete?

Programmatic solution of course... Man i wish i could choose both the VB and Unmanaged as an answer ;) Thanks for both. ...

Suitable alternative to CryptEncrypt

We have a situation in our product where for a long time some data has been stored in the application's database as SQL string (choice of MS SQL server or sybase SQL anywhere) which was encrypted via the Windows API function CryptEncrypt. (direct and decryptable) The problem is that CryptEncrypt can produce NULL's in the output, meanin...

Warning C4341 - 'XX': signed value is out of range for enum constant

When compiling my C++ .Net application I get 104 warnings of the type: Warning C4341 - 'XX': signed value is out of range for enum constant Where XX can be WCHAR, LONG, BIT, BINARY, GUID etc. I can't seem to remove these warnings whatever I do. When I double click on them it takes me to a part of my code that uses OdbcParameters - an...