I have interesting question. Why this code is legal in C, but not legal in C++ ?
(tested with GCC 4.2 compilers)

void Function() {}

int main () {
   Function(1);
   return 0;
}

We can simulate same C++ compiler error in C compiler by changing function definition to void Function(void) {} So seems that if function is declared without parameters- C++ automatically substitutes VOID as parameter in function declaration, and C - does not.

The only question here is - Does that difference between C & C++ is documented / official ? Because I've not seen that difference documented in wikipedia here
Maybe I looked not in that direction or do we need to modify wiki, huh ? :)

Recommended Answers

[QUOTE=0x69]Because I've not seen that difference documented in [URL="http://en.wikipedia.org/wiki/Compatibility_of_C_and_C%2B%2B#Constructs_valid_in_C_but_not_C.2B.2B"]wikipedia here[/URL]
Maybe I looked not in that direction or do we need to modify wiki, huh ? :)[/QUOTE]
That Wikipedia page links to [URL="http://david.tribble.com/text/cdiffs.htm"]Incompatibilities Between
ISO C and ISO C++[/URL] where …

Jump to Post

All 2 Replies

Thanks for answer. Seems wikipedia is only suitable for introduction of target domain.