Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

There is a roughly 1:1 correspondence between C++ and C, so it's just one more step to go from C to C++. Just off the top of my head...

    class data fields -> structure members
    non-static methods (ctors/dtors included) -> functions with an extra 'this' pointer parameter
    inheritance -> extended structures with matching prefices
    virtual functions -> structure with function pointers
    operator overloading -> methods with special names
    default arguments -> automatically inserted by compiler
    function overloading -> types encoded in name of function
    templates -> whatever code they generate
    exceptions -> special library functions are used, e.g. _CxxThrowException()
Some of those don't decompile so well (e.g. template-generated code, although a refactoring tool might be of help), and things like operators and overloaded functions are probably more of a stylistic choice than a difference in the generated code, but for the most part it doesn't look impossible to get some C++ features to show up in decompiled code. (And given that many of the C++-level optimisations revolve around removing unnecessary code, they could make the C to C++ step even easier.)


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: