F() vs. F(void) in C vs. C++

F() vs. F(void) in C vs. C++

One issue with C and C++’s style of code sharing and encapsulation via headers is that declarations often aren’t enough for the powerful analysis techniques of production optimizing compilers (whether or not a pointer “escapes” is a big one that comes to mind). If we change to a declaration (such as would be the case if it was defined in an translation unit, and its declaration included via header), then Clang can no longer observe whether definition differs or not from the declaration. So Clang can potentially save you a single instruction ( ) whose encoding is only 1B, per function call to functions declared in the style , but only IF the definition is in the same translation unit and doesn’t differ from the declaration, and you happen to be targeting x86_64.

Source: nickdesaulniers.github.io