"Hans Schneider" <ha**@localhost.localdomainwrote in message
news:13****************@localhost.localdomain...
Jens Thoms Toerring schrieb:
>Hans Schneider <ha**@localhost.localdomainwrote:
<program snipped>
>>This program works not with LCC-WIN32 again! Why?
>>lc -ansic -pedantic -unused shadows -O aprog.c
Pedants aren't supported any more :-)
1 error
Jacob Navia announced in a recent thread here in clc
http://groups.google.com/group/comp....edants&lnk=ol&
that lcc-win no will longer have a '-pedantic' option (or, to be
precise, will output the above text if it's used). Since it's his
compiler he can do whatever he likes with it.
Sucks.
But, if I remove -pedantic, it works still not:
lc -ansic -unused -shadows -O aprog.c
Error aprog.c: 14 invalid type specification
1 error, 0 warnings
1 error
Is signed int short bar = 0; valid C?
sure.
Q:\>type t.c
/*
* aprog.c
*
* "write a program in c."
*
*/
#include <stdio.h>
#define in "\n"
#define c
int write(const char *foo)
{
signed int short bar = 0;
const char *baz = foo;
while (baz[bar])
putchar(bar[baz++]);
return 0;
}
int main(void)
{
return write("a program" in c);
}
Q:\>cl /W4 /Ox t.c
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 14.00.50727.762 for
80x86
Copyright (C) Microsoft Corporation. All rights reserved.
t.c
Microsoft (R) Incremental Linker Version 8.00.50727.762
Copyright (C) Microsoft Corporation. All rights reserved.
/out:t.exe
t.obj
Q:\>t
a program
dcorbit@DCORBIT64 /q
$ gcc -W -Wall -ansi -pedantic t.c
dcorbit@DCORBIT64 /q
$ ./a
a program
dcorbit@DCORBIT64 /q
$ gcc --version
gcc.exe (GCC) 3.2 (mingw special 20020817-1)
Copyright (C) 2002 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
dcorbit@DCORBIT64 /q
As you can see from this diagnostic:
Q:\>splint t.c
Splint 3.1.1 --- 12 Mar 2007
t.c: (in function write)
t.c(14,12): Test expression for while not boolean, type char: baz[bar]
Test expression type is not boolean. (Use -predboolothers to inhibit
warning)
t.c(15,9): Return value (type int) ignored: putchar(baz++[bar])
Result returned by function call is not used. If this is intended, can
cast
result to (void) to eliminate message. (Use -retvalint to inhibit warning)
t.c(10,17): Function exported but not used outside t: write
A declaration is exported, but not used outside this module. Declaration
can
use static qualifier. (Use -exportlocal to inhibit warning)
t.c(17,1): Definition of write
Finished checking --- 3 code warnings
the program relies on an odd feature of the language {as explained in the
C-FAQ}:
6.11: I came across some "joke" code containing the "expression"
5["abcdef"] . How can this be legal C?
A: Yes, Virginia, array subscripting is commutative in C. This
curious fact follows from the pointer definition of array
subscripting, namely that a[e] is identical to *((a)+(e)), for
*any* two expressions a and e, as long as one of them is a
pointer expression and one is integral. This unsuspected
commutativity is often mentioned in C texts as if it were
something to be proud of, but it finds no useful application
outside of the Obfuscated C Contest (see question 20.36).
References: Rationale Sec. 3.3.2.1; H&S Sec. 5.4.1 p. 124,
Sec. 7.4.1 pp. 186-7.
** Posted from
http://www.teranews.com **