[pso] [lectura cod]

Razvan Deaconescu razvan.deaconescu at cs.pub.ro
Fri Mar 19 11:22:14 EET 2010


On Fri, 2010-03-19 at 09:56 +0200, Andrei Cibotaru wrote:
> Salut,
> 
>       Am si eu o curiozitate. In liniux kernel exista macroul urmator:

Salut!

Acea verificare, dupa cum specifica si in comentariile din nucleu[1],
este folosita pentru strict type-checking. Compilatorul va da un warning
daca se compara elemente de tipuri diferite.

La o comparatie int si char nu se da warning, dar la comparatia intre
int * si char * da warning.

Ai aici[2] un exemplu de utilizare. Mai jos este un caz de rulare

--
razvan at valhalla:~/code/macros$ gcc -Wall safe-typechecking.c 
safe-typechecking.c: In function 'main':
safe-typechecking.c:20: warning: comparison of distinct pointer types
lacks a cast
razvan at valhalla:~/code/macros$ gcc -Wall -DSAFE safe-typechecking.c 
razvan at valhalla:~/code/macros$ 
--

Razvan

[1] http://lxr.linux.no/linux+v2.6.33/include/linux/kernel.h#L598
[2] http://swarm.cs.pub.ro/git/?p=razvan-code.git;a=blob;f=macros/safe-typechecking.c;h=56188db958fe4f4b96838f6c01ac81c4d1043d20;hb=HEAD



More information about the pso mailing list