logoalt Hacker News

_kst_today at 3:15 AM3 repliesview on HN

It's not even possible to pass too few arguments to a function in C unless you go out of your way to write bad code.

You can write a function declaration that's inconsistent with its definition in another translation unit. Declaring the function in a shared header file avoids this.

You can use an old-style declaration that doesn't specify what parameters a function expects. Don't do that. Use prototypes.

You can use a cast to convert a function pointer to an incompatible type, and call through the resulting pointer. Don't do that.

You can call a function with no visible declaration if your compiler overly permissive or is operating in pre-C99 mode. Don't do that.


Replies

FartyMcFartertoday at 10:50 AM

> It's not even possible to pass too few arguments to a function in C unless you go out of your way to write bad code.

This article is exclusively about undefined behaviour. "Bad code" is already baked into the assumptions of the article.

userbinatortoday at 3:38 AM

This is a site for intellectual curiosity, not pedantic dissmisal.

show 1 reply
themafiatoday at 3:51 AM

You could also use inline assembly.