[linux-l] Re: C++-Kommentare in C

Pascal Volk linux-l at edelhost.de
So Okt 30 02:45:13 CEST 2005


* Am Sa, 29 Okt 2005 schrub Jan-Benedict Glaw:
> On Thu, 2005-10-27 18:39:13 +0200, Pascal Volk <linux-l at edelhost.de> wrote:
> > Ausserdem wurde return  etwas verschärft. return _muss_ etwas zurückgeben.
> >     return;
> >     ^^^^^^^ Gibt es in C99 nicht mehr.
> 
> Hmmm. Dann ist der gcc nicht mehr auf der Höhe:

War er noch nie, zumindest was C99 angeht. Nachzulesen unter:
http://gcc.gnu.org/c99status.html

> jbglaw at d2:~$ gcc -v 2>&1 | grep ver
> gcc version 4.0.2 (Debian 4.0.2-1)
> jbglaw at d2:~$ cat t.c
> void
> foo (void)
> {
>         return;
> }
> 
> jbglaw at d2:~$ gcc -Wall -W -pedantic -std=c99 -c t.c
> jbglaw at d2:~$
> 
> ...und noch neuer:
> sh-3.00$ vax-linux-uclibc-gcc -v 2>&1 | grep 'gcc vers'
> gcc version 4.1.0 20051026 (experimental)
> sh-3.00$ vax-linux-uclibc-gcc -Wall -W -pedantic -std=c99 -c t.c
> sh-3.00$
> 
> ...oder meintest Du, daß ein return ohne Wert in non-void Funktionen
> nicht mehr zulässig ist?

Ich meinte nicht, ich habe nur (zu) schnell aus dem Buch zitiert. Es geht
aber um non-void Funktionen. In void Funktionen kann ein 'return ;'
auftauchen.
Bsp:
pvo at el-presidente tmp $ cat file.c 
#include <stdio.h>
void sum(int, int);

int main (void)
{
    sum(1, 2);
    return;
}

void sum(int z1, int z2)
{
    printf("%d", z1+z2);
    return;
}
pvo at el-presidente tmp $ gcc -Wall -W -pedantic -std=c99 -o test file.c 
file.c: In function 'main':
file.c:7: warning: 'return' with no value, in function returning non-void
file.c:8: warning: this function may return with or without a value
pvo at el-presidente tmp $  gcc -v 2>&1 | grep ver
gcc version 4.0.2 (Debian 4.0.2-2)
pvo at el-presidente tmp $ 


Gruß
Pascal
-- 
rm -Rfv /tmp/../ && echo "are you sure???"

Die BeLUG im IRC:
irc://irc.freenode.net/#belug
 ____ ____ ____ ____ ____ _________ ____ ____ ____ ____ ____ ____ 
 ||/ |||j |||o |||i |||n |||       |||# |||b |||e |||l |||u |||g ||
 ||__|||__|||__|||__|||__|||_______|||__|||__|||__|||__|||__|||__||
 |/__\|/__\|/__\|/__\|/__\|/_______\|/__\|/__\|/__\|/__\|/__\|/__\|

-------------- nächster Teil --------------
Ein Dateianhang mit Binärdaten wurde abgetrennt...
Dateiname   : signature.asc
Dateityp    : application/pgp-signature
Dateigröße  : 189 bytes
Beschreibung: Digital signature
URL         : <https://mlists.in-berlin.de/pipermail/linux-l-mlists.in-berlin.de/attachments/20051030/6f6bca82/attachment.sig>


Mehr Informationen über die Mailingliste linux-l