Mail Archives: djgpp/2001/10/10/13:04:12
GCC does some very nice Syntax Checking
(more than some compilers do)
and yes, GCC also has the annoying habit of SOMETIMES
missing the point about a syntax error, or not telling you the
correct information about an error.
I use several different compilers myself. I know for a fact GCC
nags about things other compilers miss; on the other hand,
defining main simply:
main(...argv,...argc)
should indeed DEFAULT to the int main(...argv,...argc) construct,
but doesn't (older compilers would have no problemwith this).
Try porting msvc to any professional compiler; THEN you'll have
something to really complain about and lose sleep over ;-)
On Tue, 09 Oct 2001 20:33:27 GMT, Martin Ambuhl
<mambuhl AT earthlink DOT net> wrote:
>tenbux wrote:
>>
>> Hi all,
>>
>> I was working on a fairly simple lab for a CS class, and using DJGPP
>> to compile and test my programs. Here is some sample code I had
>> written:
>>
>> #include <stdio.h>
>>
>> struct bit {
>> int bit;
>> struct bit *next;
>> }
>>
>> main(int argc, char *argv[])
>> {
>> int x;
>> FILE *in, *out;
>>
>> if (argc < 3) {
>> puts("Usage: binprint <numbers> <output>");
>> return;
>> }
>>
>> if ((in = fopen(argv[1], "r")) == NULL) {
>> printf("Error opening input file: %s\n", argv[1]);
>> return;
>> }
>>
>> You'll notice that there is no semicolon after the struct declaration
>> (as is required). But gcc didn't catch this, instead it warned me
>> about main not being declared as int.
>
>gcc caught it. You declared main as returning a struct bit instead of
>an int. It told you about, but ...
>
>> So when I ran the binary with no
>> arguments,
>
>you ignored the warning and got what you deserved.
>
>> Is this a current bug or is it supposed
>> to act that way? :)
>
>Don't blame the compiler for your errors.
- Raw text -