Hacker News new | past | comments | ask | show | jobs | submit login

There's no replacement for exceptions, but you can use setjmp and longjmp if you really want to jump out many layers of nested calls.

In C11 there is type generic macros that helps writing C++-like overloaded functions.

There are several extensions in GCC too.

For RAII-like memory management, there are __attribute__((constructor)) and __attribute__((destructor)).

C++ does type reflection on constant expressions via type traits templates, in GCC there is simply typeof().

If you are bored about writing static function modifiers, you can write a function inside function.

If you want to allocate a vector which won't change capacity and be released when out of local scope , for example in C++:

    auto v = std::vector<int>(n);
With C99 dynamic arrays you can use this instead:

    int v[n]; // n is a variable determined at runtime
You can use the union trick to achieve safer type casts too.

Applications are open for YC Winter 2020

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