Van's House

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

  • Van's House

    System.Uri doesn’t allow embedded escaped slashes

    • 6 Comments
    I use C# a lot to write small utilities and sometimes find that it is annoying to have to dig into the source code to figure out why .Net framework doesn’t work as I expected. This happens again when I am using LinkedIn API (BTW, this is the first occurence...
  • Van's House

    Optimize Your Code: Matrix Multiplication

    • 4 Comments
    Matrix multiplication is common and the algorithm is easy to implementation. Here is one example: Version 1: template < typename T> void SeqMatrixMult1( int size, T** m1, T** m2, T** result) { for ( int i = 0; i < size; i++) { for ( int j...
  • Van's House

    Enable syntax highlighting for TR1 headers in VS2008 SP1

    • 3 Comments
    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...
  • Van's House

    Standard library changes in C++0x

    • 3 Comments
    C++0x will be released in the near future. Do you know the changes of standard library? Here is a list of changes that I've collected (minor behavior changes and changes related to concepts are not included). 1. New stuff system_error: new header array...
  • Van's House

    VC extensions list

    • 2 Comments
    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...
  • Van's House

    C++ Template Trick: Detecting Object Slicing

    • 2 Comments
    Object slicing often happens when you pass the object by value. Compiler will do implicitly conversion from derived to base for you without any warning message. If you want to detect object slicing, you're on your own. However, template can help you...
  • Van's House

    Online C++ Compilation Service

    • 2 Comments
    There are many useful online c++ compilation service providers. You can use them to do conformance test and portability test without purchasing and installing various kinds of compilers. The following sites are the most famous: http://www.dinkumware...
  • Van's House

    C++98 -> C++11: Pass by value or pass by reference?

    • 2 Comments
    In GoingNative 2012 , there are some discussions on the new coding style for C++11. One interesting thing which is mentioned by Bjarne Stroustrup, Stephan T. Lavavej and Herb Sutter is the most efficient way to pass the argument. In C++98, pass by...
  • Van's House

    VC's "evil" extension: $

    • 2 Comments
    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...
  • Van's House

    Connect Bugs that I Fixed

    • 2 Comments
    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...
  • Van's House

    Debug vs Release - v2

    • 1 Comments
    Four and half a year ago (how time flies), I wrote a post about the potential issues mixing debug and release CRT in the same program. At the end, it says, 'It's fortunate that this is a linker error. Otherwise, you'll waste lots of time in debugging...
  • Van's House

    Speed up iostream

    • 1 Comments
    Throughput of iostream is considered much slower compared with its C counterpart. For example: printf( "1234567\n" ); cout << "1234567" << endl; If you iterate 10 5 times, printf takes about 50ms while cout takes >1s. This looks...
  • Van's House

    IDA Pro 5.5 is released

    • 1 Comments
    IDA Pro 5.5 ships 12th of June 2009. The change list is here: http://www.hex-rays.com/idapro/55/index.htm
  • Van's House

    C++0x features in VC2010 - auto

    • 1 Comments
    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...
  • Van's House

    Conformance macros in VC STL

    • 1 Comments
    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...
  • Van's House

    Debug vs Release

    • 1 Comments
    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...
  • Van's House

    Magic behind ValueType.Equals

    • 1 Comments
    In "Effective C#", Bill Wagner says "Always create an override of ValueType.Equals() whenever you create a value type". His main consideration is the performance, because reflection is needed to compare two value types memberwisely. In fact, the framework...
  • Van's House

    Play with the C++ compiler - compile nightmare

    • 1 Comments
    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...
  • Van's House

    Obfuscate your code

    • 1 Comments
    Obfuscation is widely used to protect your code from reverse engineering. Here is one example which takes advantage of indirected call and opcode overlap in X86: __declspec ( naked ) void Fun1() { __asm { //obfuscation chunk call LABEL1 LABEL1: pop eax...
  • Van's House

    Minimize the size of your program - high level

    • 1 Comments
    NOTICE: The following is not intended for real-world application. It is just an intellectual exercise to minimize the size of the program. The generated PE file may or may not be valid as it depends on behavior of specific architecture, OS and toolset...
  • Van's House

    Minimize the size of your program - assembly source

    • 1 Comments
    ; based on tiny.asm, modified by xiangfan ;e_cblp 2b ;tbl 1b ;hexstr 1b ;LoaderFlags 4b BITS 32 ; ; MZ header ; ; The only two fields that matter are e_magic and e_lfanew mzhdr: dw "MZ" ; e_magic dw 0 ; e_cblp UNUSED ; ; PE signature ; pesig: dd "PE"...
  • Van's House

    Minimize the size of your program - low level

    • 1 Comments
    NOTICE: The following is not intended for real-world application. It is just an intellectual exercise to minimize the size of the program. The generated PE file may or may not be valid as it depends on behavior of specific architecture, OS and toolset...
  • Van's House

    IDA Pro 5.3 Demo is released

    • 1 Comments
    IDA Pro is the world-class disassembler. It's a very useful reverse engineering tool. Now the demo of the newest version 5.3 is available: IDA Pro 5.3 demo download You can also try the freeware version (a little out of date): IDA Pro 4.9 Freeware
  • Van's House

    Protected or Private?

    • 1 Comments
    As the designer of base class, you may hesitate whether to use private or protect access control. Then, let's try the following examples: 1. Call protected member function #include <cstdio> class A { protected : void b() {printf( "Oops!\n" );...
  • Van's House

    Contiguousness of STL containers and string

    • 1 Comments
    In C++, it is well-known that the data in the vector is contiguous. To be more specific, here is the quotation from the standard (C++03, 23.2.4/1) The elements of a vector are stored contiguously, meaning that if v is a vector<T, Allocator> where...
Page 1 of 2 (43 items) 12