oui bits

Portrait de trax

A small C code, guess what does it do and how!
(Good luck and sorry for the warning)

%:define A(_) \
struct <%short o;int O;%>O;O.O=_,O.o=3<:&O.o:>;int a=O.o^O.o;float O_o=a; \
while (O.o --> 1)\
a += (((~((O.o&3)+1)[%:_])&1)?1:-1), O_o+=a/(1.0+O.o);\
http://clubnix.fr

int main(){
A('KILL');
//if you found what this code do:
goto http;//clubnix.fr
return 0;
}

Commentaires

Portrait de paul

Hum je n'arrive pas à compiler ta merde !

13:51 paul@gen3 ~/tmp% gcc -Wall -o trax trax.c 
trax.c: In function ‘main’:
trax.c:8:9: attention : constante caractère multi-caractères [-Wmultichar]
 A('KILL');
         ^
13:51 paul@gen3 ~/tmp% vim trax.c              
13:52 paul@gen3 ~/tmp% gcc -Wall -o trax trax.c
trax.c: In function ‘main’:
trax.c:2:31: attention : assignment makes integer from pointer without a cast [enabled by default]
 struct <%short o;int O;%>O;O.O=_,O.o=3<:&O.o:>;int a=O.o^O.o;float O_o=a; \
                               ^
trax.c:8:1: note: in expansion of macro ‘A’
 A("KILL");
 ^
Portrait de paul

Hum il semblerait que je ne sois plus habitué aux messages d'erreur de GCC !

Portrait de trax

1. passe ton système en anglais (je sais c'est gratuit)
2. c'est un warning/attention donc ça compile quand même
=> oui c'est mal, mais c'était quand même écrit dans la deuxième ligne de l'article qu'il y en avait un
3. qu'est ce que tu as fait entre la première et la deuxième compile ?

2B G33K || !2B

Portrait de romain

Pas mal !
On peut aussi initialiser O_o à 4, inverser la condition ternaire ("1:-1" ==> "-1:1") et
transformer "O_o+=a" en "O_o+=4*a".
En bonus la précision est meilleure.
Reste plus qu'à comprendre pourquoi