On Sat, 31 May 2003 16:08:49 +0200 Philipp Thomas <philipp.thomas@t-link.de> wrote:
I should have been more precise, sorry. At least C89 allows it (can't check ISO C98 as it's at work). It's the compiler that can't distinguish between empty parameter list and K&R definition and thus won't flag passing parameters as an error. This is true to some extent. A good compiler should be able to catch the error in some cases. Lint on Tru64 Unix was able to do it, and it used a YACC parser. It is relatively easy for the compiler if the function is defined first. But, I don't think that gcc has that capability.
That's why I *always* change code to use void and have caught a few bugs in packages where functions first took a parameter and later none but as there was only a K&R prototype the compiler didn't catch it. It is a good practice to always use ANSI prototypes and ANSI function definitions. The only exception might be main() which is a special case in that it takes either 0 or 2 parameters (or 3 in archaic cases).
In C++, an empty parameter list is equivalent to using void as the parameter list since C++ does not permit K&R function types. But, other than the howto, in answer to the original person's question, "s read() evil in usermode", the answer is no. It is appropriate to use standard Unix/Linux system calls in any code that is intended for use in a Unix-like system. My only comment is that it is better to use the more portable interfaces, which is why I used termios(3) and not ioctl(2). Additionally, read(2), write(2), open(2) and close(2) are normally available in non-Unix systems. -- Jerry Feldman <gaf@blu.org> Boston Linux and Unix user group http://www.blu.org PGP key id:C5061EA9 PGP Key fingerprint:053C 73EC 3AC1 5C44 3E14 9245 FB00 3ED5 C506 1EA9