It is too clear and so it is hard to see.
A dunce once searched for fire with a lighted lantern.
Had he known what fire was,
He could have cooked his rice much sooner.
Are you sure you did not compile as C++? It works for me when compiling as C.Originally Posted by vart
EDIT:
Wait a minute, I assumed that King Mir meant 'this will not (compile with a "too many arguments" error)' (which does not really make sense, I suppose), but maybe King Mir meant 'this will (not compile) with a "too many arguments" error', in which case the reason why this is not so is that the definition is also a declaration.
EDIT #2:
hmm... but the language of C99 seems to indicate otherwise:
The wording "not part of a definition" seems to say that although a definition is a declaration, the fact that it is a definition trumps the fact that it is a declaration for the interpretation of an empty parameter list. If this is so (and also in C90), then gcc and MSVC are both non-conformant in this area.Originally Posted by Section 6.7.5.3, Paragraph 14
Last edited by laserlight; 04-04-2009 at 12:25 AM.
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
I compiled it as C
VS2005 gives no errors
gcc port used in CodeBlocks - gives the error specified by King Mir
All problems in computer science can be solved by another level of indirection,
except for the problem of too many layers of indirection.
– David J. Wheeler
What is the version of gcc? The MinGW port of gcc 3.4.5 did not emit such an error for both C90 and C99 mode with -Wall and -pedantic tacked on.Originally Posted by vart
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
ok I played a little with the CodeBlocks installation to see exactly which gcc is configured, what switches are set, and finally - what command line it uses to compile a file.
Here is it:
1. gcc is 3.4.5 and it does not show the error. (I have running it from command prompt)
2. CodeBlocks on some reason starts g++ to compile the c-file
So - about the second - how do I tell to CodeBlocks that *.c files should be compiled as C and not C++?
All problems in computer science can be solved by another level of indirection,
except for the problem of too many layers of indirection.
– David J. Wheeler
I think this might work: click on the .c file and select "Properties...". Click on the "Advanced" tab and change "CPP" to "CC" for the "Compiler variable" setting.Originally Posted by vart
EDIT:
No, Code::Blocks does not seem smart enough to use gcc instead of g++ in that case.
Last edited by laserlight; 04-04-2009 at 01:26 AM.
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
My take on the whole was:
I could be wrong, though.Code:void fun(void); // No parameters void fun(); // No parameter information (infinite parameters) void fun(void) { } // No parameters void fun () { } // No parameters
Although VS would let the last example compile.