??: ??: pws kanw install to GCC 4.0.2?

Giorgos Keramidas keramida at ceid.upatras.gr
Tue Jan 17 00:12:21 EET 2006


On 2006-01-16 23:42, underzero at in.gr wrote:
>
> To programma einai gia ena mathima sto panepistimio. To ekana compile
> me gcc xxx.c To problhma den briskete ston compiler alla fisika sto
> programma mou.

Ok.  Tote mporei na xreiastei na _doyme_ to programma h estw na to
kaneis build me ta flags pou tha sou poume kai na mas peis ta warnings
pou bgazei.

> Aplos exoun ginei kapoies alages pisteuw sto neotero gcc kai etsi
> bgazei sfalma se kapoio shmeio opou o palioteros den ebgaze.  px an
> thimamai kala na kaneis printf("%d",p); kai o p einai enas pointer kai
> einai NULL o gcc 3.3.5 tha ektupwsei (null) eno o 3.4 tha bgalei
> segmentation fault. Kati antistoixo tha ginete kai sto programma mou.

Kai poly kala kanei.  To mege8os enos `int' den einai aparaithta arketa
megalo gia na xwresei thn timh enos pointer.  P.x. se kapoia mhxanhmata
(opws to laptop pou grafw twra thn apanthsh) an trekseis to parakatw
programma:

     1  #include <stdio.h>
     2  #include <stdlib.h>
     3
     4  int
     5  main(void)
     6  {
     7          printf("sizeof int = %llu\n", (unsigned long long)sizeof(int));
     8          printf("sizeof void * = %llu\n", (unsigned long long)sizeof(void *));
     9          return EXIT_SUCCESS;
    10  }

8a deis to ekshs:

    $ ./foo
    sizeof int = 4
    sizeof void * = 8
    $

Etsi h printf() sou 8a perimenei 4 bytes (apo to `%d' format) kai 8a
parei ksafnika 8 bytes.  Einai idiaitera endiaferon alla mh problepsimo
to apotelesma.  Mporei na crasharei to programma.  Mporei na paiksei mia
xara.  Mporei ksafnika na arxisoun na bgainoun daimones apo th myth sou
kai na dior8wsoyn ton kwdika, prin prolabei h CPU na ton treksei, opote
na treksei pali mia xara... kaneis den kserei :-(

> Opote thn nea ekdosh thn thelw gia na mhn exw pleon problhma
> asimbatothtas me to compiler tou panepistimiou.

Mia xara einai ki ayth pou exeis.  Dokimase na kaneis build to programma
sou toulaxiston me ta parakatw options kai pes mou ti blepeis:

	gcc -O2 -fno-strict-aliasing -pipe \
	    -g -Wsystem-headers -Wall -Wno-format-y2k -W \
	    -Wno-unused-parameter -Wstrict-prototypes \
	    -Wmissing-prototypes -Wpointer-arith -Wreturn-type \
	    -Wcast-qual -Wwrite-strings -Wswitch -Wshadow \
	    -Wcast-align -Wunused-parameter -Wchar-subscripts \
	    -Winline -Wnested-externs -Wredundant-decls \
	    -o koko koko.c

Apo ta warnings pou 8a deis, einai poly pi8anon na anakalupseis akribws
to problhma pou exei to programma akoma kai se 3.X GCC.

> To linux pou exw einai suse 9.3 pro 64bit (apo to DVD tou RAM).

Eidika sta 64-bit programmata, xreiazetai *POLY* proxoxh otan grafeis
kwdika, epeidh den isxuoun polla apo ta "default" pragmata pou exei
synh8isei kapoios otan douleuei me 32-bit mhxanhmata.

Akoma kai to na leipei ena "function prototype" se 64-bit mhxanhmata,
einai polles fores 8anasimo lathos, afou o compiler 8ewrei oti to return
type mias function einai `int', me tragika apotelesmata otan h function
sthn pragmatikothta einai orismenh ws:

    char *function(...);

> To programma tha eprepe na dhmeiourgei kapoia structs me dedomena (me
> malloc ktl).  Sto panepistimio omws kathws pernaei ta dedomena apo
> arxeio petaei ena "bus error".

An de 8es na steileis sth lista to programma, pou einai katanohto,
mporeis na mou to steileis me proswpiko email kai 8a sou pw giati skaei.

Tis dior8wseis, prepei, fysika na tis kaneis monos sou.




More information about the Linux-greek-users mailing list