Schauble@mit-multics.arpa (03/30/87)
This is a followup on my recent message about error checking in Microsoft C V4.0. The problem in that message was: Within one file I have the function declaration void bgunlink_transaction_record (bgfile, client, transaction) BGFILE *bgfile; struct tclient_rec *client; struct ttransaction_rec *transaction; { .... } The type BGFILE and the structures are correctly declared prior to this. Later in the file I have the statement bgunlink_transaction_record (&bgfile, &client_rec, rec, &transaction); Note that they don't match in number or types of arguments. When compiling with /W3 for maximum checking, the compiler SAYS NOT A WORD ABOUT THIS. On thinking about it more, this seemed even stranger. The compiler does process function declarations to get the return type. That is, the program fragment: int f(i,p) int i; char *p; {} void main() { int i; char *p, *z; z = f(p,5); } produces a warning about the assignment to z (int assigned to char *) but not about the argument mismatch. Adding the line int f(char *, int *); causes a warning about the assignment, but again not about the argument mismatch. I believe that this is a violation of the proposed ANSI standard in that this redefinition of f is not allowed. Would someone who has a copy of the standard please check. And finally, most curiously of all, deleting the function definition and leaving only the prototype now produces the warning about argument mismatch. Note that the arguments were apparantly not checked even when the prototype was present if the function was present. Having the function itself in the same compilation should certainly not suppress argument checking. There's something wrong here. Paul .
root@sdd.UUCP (04/03/87)
In article <6375@brl-adm.ARPA> Schauble@mit-multics.arpa (Paul Schauble) writes: > >And finally, most curiously of all, deleting the function definition and >leaving only the prototype now produces the warning about argument >mismatch. > > > Paul . Why don't you declare your functions as follows: f(int i, char *p); That might work. It's possible that Microsoft C 4.0 is attempting compatiblity with ANSI compatible code as well as pre-ansi compatible code! Daniel Corbett
ugwayne@sunybcs.UUCP (04/06/87)
Paul, When using the Microsoft C compiler version 3 or 4, it is necessary to #define LINT_ARGS in your program or by using the /D option when you compile to enable type checking on library calls. For more information, refer to page 78 in the Microsoft C 4.0 User's Guide. Wayne Nelligan SUNY at Buffalo Computer Science ------------------------------------------------------------------------- .{bbncca,decvax,dual,rocksvax,watmath,sbcs}!sunybcs!ugwayne CSNET: ugwayne@Buffalo.CSNET ARPANET: ugwayne%Buffalo@csnet-relay.ARPA BITNET: ugwayne@sunybcs.BITNET