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

I'm currently on a C++ (mostly C with C++ compiler) trip. It does make some things easier and some things harder. It makes it easier to work with C++ developers :-). I sometimes use the more involved C++ features but often regret it after because of complications.

But one thing that makes it worth it is the removal of the struct tag space. I have a strong dislike for the struct tag boilerplate in C, but the alternative -- typedef boilerplate -- in C is unbearable to the point that I have a macro to define structs in C that does this automatically.

    #define STRUCT(name) typedef struct name name; struct name

    STRUCT(Foo) {
        int x;
        int y;
    };
But macros often come with disadvantages. In this case it's that many IDEs have trouble finding the struct definitions from a usage site.


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

Search: