Hacker News new | ask | show | jobs
by nsguy 808 days ago
Don't include the standard headers and just put it the definition for the symbols you're using. With std::cout you might end up pulling your hair out to find everything but I can't imagine it'd be more than a few dozen lines... Not gonna try ;)

With C you just need a definition for printf instead of including stdio. In the old days you'd get by without even defining it at all.

2 comments

In C, you can get away with just this (no includes or definitions):

    void main() { puts("Hello, World!"); }
You get a warning, but it is fine.
> In the old days you'd get by without even defining it at all.

GCC and Clang have a `__builtin_printf()` instead, quite useful for adhoc printf-debugging without having to include stdio.h. Under the hood it just resolves to a regular printf() or puts() stdlib call though.