954,496 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Differences between C & C++ compilers

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 ? :)

0x69
Junior Poster
131 posts since Apr 2010
Reputation Points: 51
Solved Threads: 9
 
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 ? :)


That Wikipedia page links to Incompatibilities Between
ISO C and ISO C++
where this is explained, see the section "Empty parameter lists".

mitrmkar
Posting Virtuoso
1,809 posts since Nov 2007
Reputation Points: 1,105
Solved Threads: 395
 

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

0x69
Junior Poster
131 posts since Apr 2010
Reputation Points: 51
Solved Threads: 9
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: