The Great C Runtime (CRT) Refactoring

The C Runtime is being refactored… Note CRT is being refactored. The implementation is split into different modules. Read more here: http://blogs.msdn.com/b/vcblog/archive/2014/06/10/the-great-crt-refactoring.aspx  Relevant excerpt from above blog post: In order to unify these different CRTs, we have split the CRT into three pieces: VCRuntime (vcruntime140.dll): This DLL contains all of the runtime functionality required for […]
Continue reading…

 

Troubleshooting side by side issues using sxstrace

Side by side errors are troublesome to troubleshoot. You run an MFC/CRT application on customer machine and you run into error dialogs similar to the one shown below… Don’t get overawed by the error. Its quite easy to troubleshoot, hmm well. As the error message suggests let use sxstrace.exe. The usage of sxstrace is pretty […]
Continue reading…

 

[Interop] Call into .net/managed code from native/unmanaged code

Introduction I’ve got a native console application which would like to call into a piece of managed code written in C#. This is the how the C# function “Sum” looks like… My solution explorer looks as follows… CSharpModule is a CSharp library while TestManagedCall is a native/unmanaged project. My requirement is as follows: call Class1.Sum […]
Continue reading…

 

[C/C++] Floating point comparisons with NaN giving inconsistent results

You might notice that when comparing with NaN, the comparison gives wrong results at least for x64 builds. Take a look at the following piece of code. If you run this sample application the comparison statement if(lfv==0.0) returns true and the MessageBox is displayed. (We had a customer who reported this behavior.) #include “stdafx.h” #include […]
Continue reading…

 

C/C++ Interview Question: Why Executable file differs in size

I have following code snippets… Code snippet 1 int arr[1000000]; int main() { return arr[0]; } Code snippet 2: int arr[1000000] = {10}; int main() { return arr[0]; } After compilation of the above snippets the output exe differs in size. The second snippet’s executable is much bigger in size than the first snippet’s executable. […]
Continue reading…

 

Where is TstCon: ActiveX test container

Long back we used to have an ActiveX test container called TstCon, which was used for debugging our ActiveX controls. I went looking for the container and found it in the samples folder, Ideally it will be the following sample folder… rootAllVCLanguageSamplesC++MFColeTstCon More of why this tool was moved out of the standard tools that […]
Continue reading…

 

Turn on/off buffering for streams in c++

Use io manipulator ‘unitbuf’ to turn off stream buffering and ‘nounitbuf’ to turn on stream buffering. If ‘unitbuf’ is on the stream object is flushed after every insertion else the stream is not force flushed. For e.g. endl triggers a flush in cases of ‘nounitbuf’. Sample code: fstream fstr( “c://Hello.txt” ); [sourcecode language=”cpp”]cout << unitbuf […]
Continue reading…

 

Technical Interview question: Stack growth direction

This one is a brain teaser for my native programmers. Prove via code the direction of a threads’ stack growth i.e is it upwards or downwards. Post your answer as a comment. I’ll post mine in a while.
Continue reading…