Van's House

I'm a developer at C++ team. I'm interested in everything related to C++

Browse by Tags

Tagged Content List
  • Blog Post: Connect Bugs that I Fixed

    Similar to STL's post on vcblog , I generate a table of connect bugs that I have fixed after I officially worked on the compiler front end: Connect ID Title 581680 Lambda declaration cannot access closure variables when defined as a member function of an inline class ...
  • Blog Post: November CTP of Visual C++ compiler, more C++11 features

    Our team announced Novemeber CTP of Visual C++ compiler . It contains the following C++11 features besides those already in VS2012: Variadic templates Uniform initialization and initializer_lists Delegating constructors Raw string literals Explicit conversion operators Default...
  • Blog Post: C++: Under the Hood

    This is an article written by Jan Gray. It is quite old, but most of the contents still apply today. The original article on MSDN can no longer be found. Here is the pdf version on OpenRCE: http://www.openrce.org/articles/files/jangrayhood.pdf . Overview: How are classes laid out? How are data members...
  • Blog Post: C++0x features in VC2010 - nullptr

    Summary Page ( n3090.pdf is the current working draft of C++0x standard, it is available at http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2010/n3090.pdf ) What we have before C++0x Everyone knows that null pointer value is NULL. In C++, NULL is defined as follows: #define NULL...
  • Blog Post: C++0x features in VC2010 - some decltype bugs

    1. decltype(*&function) https://connect.microsoft.com/VisualStudio/feedback/details/510640 int foo(); decltype (*&foo) df; // it should be "int (&)()", but it is "int (*)()" The internal representation (it is special for "*&function") doesn’t contain the enough information...
  • Blog Post: C++0x features in VC2010 - decltype

    Summary Page ( n3090.pdf is the current working draft of C++0x standard, it is available at http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2010/n3090.pdf ) What we have before C++0x When do generic programming in C++, you often have to generate type from template parameters. Type traits...
  • Blog Post: C++0x features in VC2010 - auto

    Summary Page ( n3090.pdf is the current working draft of C++0x standard, it is available at http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2010/n3090.pdf ) What we have before C++0x C++ is a strongly typed programming language. You have to specify the type when declaring variables. Sometimes...
  • Blog Post: C++0x features in VC2010 - static_assert

    Summary Page ( n3090.pdf is the current working draft of C++0x standard, it is available at http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2010/n3090.pdf ) What we have before C++0x It is a common task to output meaningful error message from source code based on compile-time conditions...
  • Blog Post: C++0x features in VC2010 - Summary

    VC2010 has been released for a while. It adds many C++0x features (The complete list can be found here: C++0x Core Language Features In VC10: The Table ) In the following posts, I’d like to share some of my experience of these new features. They will cover: What we have before C++0x What...
  • Blog Post: VC's "evil" extension: Pre-definition of basic types

    In VC, you may find that you can use "size_t" directly without including any headers. size_t i = 0; int main() { atexit(0); } However, "size_t" is not a built-in type. It is a typedef in <stddef.h>. So what's the magic? In VC compiler, it will include some internal headers for various reasons...
  • Blog Post: VC's "evil" extension: Implicit definition of static constant member

    C++ supports in-class initialization of static integral constant members. It is nearly the same as enum, with the following difference (quoted from C++03 9.4.2.4 ([class.static.data])): The member shall still be defined in a namespace scope if it is used in the program and the namespace scope definition...
  • Blog Post: VC's "evil" extension: $

    In C++, only a few characters can be used as part of the identifier. identifier: identifier-nondigit identifier identifier-nondigit identifier digit identifier-nondigit: nondigit universal-character-name other implementation-defined characters nondigit: one of a b c d e f g h i j k l m n o p q r s...
  • Blog Post: Output Text in Unicode

    According to C standard, it only supports output text in MBCS (Multi-Byte Character String): n1124.pdf , 7.19.3/12 The wide character output functions convert wide characters to multibyte characters and write them to the stream as if they were written by successive calls to the fputwc function. Each...
  • Blog Post: Detect Shift Overflow

    This is an intellectual exercise: when shifts a 32-bit unsigned integer in C++, how to detect whether the calculation overflows efficiently? Here is the function prototype. shl_overflow will return true if v << cl overflows (cl is between 0 and 31. And we assume that sizeof(unsigned long) =...
  • Blog Post: Recursive Algorithm in C++

    Many recursive algorithms have initial parameters. For example, Fibonacci Number is defined as: Fn = Fn-1 + Fn-2, with F1 = F2 = 1. By giving different values to F1 and F2, we can generate different sequence of numbers. 1. If we implement the algorithm using functions, we have to either define...
  • Blog Post: Measure Initialization Time of Global Variables

    NOTICE: The technique describes in the article may not be supported in future release of VC. You should not use it in production code There are two kinds of initialization in C++: static initialization and dynamic initialization. According to the standard, static initialization shall always be...
  • Blog Post: Enable syntax highlighting for TR1 headers in VS2008 SP1

    Unfortunately, VS2008 SP1 doesn't recognize C++ tr1 headers. That means there are no syntax highlighting and no intellisense for these files. This is a bug, but you can fix it by yourself. The trick is in the registry. VS maintains a list of extensionless files, and will treat them as cpp files. ...
  • Blog Post: VC extensions list

    MSDN has a page describing various VC extensions. But it is far from complete. I've collected a list of nonstandard extensions provided by VC, some of them are evil . If you want to write standard conformant C++ code, you'd better be aware of these extensions which are on by default. Some commonly...
  • Blog Post: Play with the C++ compiler - compile nightmare

    Playing with the compiler is interesting. One challenge for the compiler writer is compilation performance. There're many kinds of C++ code which are the nightmare for the compiler. Now let's go! 1. Preprocess a. Self Inclusion (GCC only) Normally, the compiler will limit the nest level of inclusion...
  • Blog Post: Debug vs Release

    Someone may wonder what the difference is between Debug and Release mode, and whether it is possible to mix them. Here is one example: http://forums.msdn.microsoft.com/en-US/vcgeneral/thread/775ce067-b225-4141-8b86-2d7e9b61db97/ syperk said: "As a result, I've switched to compiling my debug builds...
  • Blog Post: Conformance macros in VC STL

    In VC STL, there are two macros called "_HAS_IMMUTABLE_SETS" and "_HAS_STRICT_CONFORMANCE" which are defined in yvals.h. They are related to some defects in the C++ standard 2003. 1. _HAS_IMMUTABLE_SETS will influence the constness of set::iterator. Associative containers require its elements to...
Page 1 of 1 (21 items)