When you write:
void test_print() { ... }
you did not provide a function prototype, so the compiler should not compare calls with a list of arguments. To provide a prototype, you must write an explicit void :
void test_print(void) { ... }
Or provide a separate prototype declaration:
void test_print(void);
But it’s best if the function definition matches the prototype declaration, so always write void . And yes, this is one area where C ++ differs from C. You cannot use a function in C without a prototype in scope, and C ++ can treat an empty argument list as an empty argument list. On C99 or later, it is assumed that you have a prototype in scope, but it is usually not used by the compiler unless you add more stringent parameters ( -Wmissing-prototypes -Wstrict-rprototypes -Wold-style-definition -Wold-style-declaration - possible options for GCC). But the requirements of backward compatibility with the preliminary C standard meant that C89 cannot force the use of “empty parentheses”, this means that there are no arguments without breaking much of the previously valid C code, which would prevent the standard from being acceptable.
source share