<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-20659215</id><updated>2011-04-22T05:40:26.716+02:00</updated><category term='jeu'/><category term='programmation'/><title type='text'>GamesOver's Blog</title><subtitle type='html'>Le but de ce blog est de donner des informations qui devraient pérenniser. Cela peut aller de la résolution d'un problème avec un programme, à de la programmation pur et simple.</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://sky13.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20659215/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://sky13.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Sky13</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>3</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-20659215.post-3214686911839995314</id><published>2007-07-08T22:50:00.000+02:00</published><updated>2007-07-08T23:18:03.983+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='programmation'/><title type='text'>Un système de "logging" en C</title><content type='html'>&lt;div style="text-align: justify;"&gt;Je travail sur une librairie depuis quelques mois et je désirais y intégrer un système de "logging". Le but est donc de pouvoir suivre ce que fait cette librairie lors de son utilisation. J'ai découvert les fonctions &lt;span style="font-style: italic;"&gt;vprintf&lt;/span&gt;, etc,.. qui se comportent exactement comme les fonctions &lt;span style="font-style: italic;"&gt;printf&lt;/span&gt;, mais qui ont le mérite de prendre une &lt;span style="font-style: italic;"&gt;va_list&lt;/span&gt; comme argument. Du coup, c'est extrêmement pratique pour un système de "logging".&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;Deux en-têtes sont donc indispensables. Les &lt;span style="font-style: italic;"&gt;vprintf&lt;/span&gt; appartiennent au &lt;span style="font-style: italic;"&gt;stdio.h&lt;/span&gt; tout comme les &lt;span style="font-style: italic;"&gt;printf,&lt;/span&gt; et le &lt;span style="font-style: italic;"&gt;va_list&lt;/span&gt; est disponible depuis le &lt;span style="font-style: italic;"&gt;stdarg.h&lt;/span&gt;. Cet article sous-entend donc que vous connaissez déjà ces deux en-têtes. Et donc que vous savez que le &lt;span style="font-style: italic;"&gt;stdarg&lt;/span&gt; à le mérite de permettre d'écrire des fonctions à paramètres optionnels.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-size:130%;" &gt;Les messages de log&lt;/span&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;Nous voulons par exemple générer un message dans le &lt;span style="font-style: italic;"&gt;stderr&lt;/span&gt; à  l'aide de notre fonction de log. Mais dans ce message on aimerait pouvoir passer des valeurs de variables. Comme par exemple:&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:courier new;"&gt;my_log(&lt;span style="color: rgb(255, 0, 0);"&gt;"variable x=%i, variable y=%s"&lt;/span&gt;, my_int, my_string);&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;Il est donc nécessaire de considérer que plusieurs variables peuvent être entrées tout comme pour une fonction &lt;span style="font-style: italic;"&gt;printf.&lt;/span&gt; Donc notre fonction &lt;span style="font-style: italic;"&gt;my_log()&lt;/span&gt; doit forcément accepter un nombre optionnel de paramètres.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Exemple:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;static void&lt;/span&gt; my_log(&lt;span style="color: rgb(153, 0, 0);"&gt;const char&lt;/span&gt; *msg, ...) {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color: rgb(255, 255, 255);"&gt;..&lt;/span&gt;&lt;span style="color: rgb(153, 153, 153);"&gt;// (...)&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;Maintenant essayez d'imaginer l'implémentation de cette fonction si vous utilisiez &lt;span style="font-style: italic;"&gt;printf&lt;/span&gt; ou &lt;span style="font-style: italic;"&gt;fprintf&lt;/span&gt;. Il serait nécessaire de récupérer chaque paramètres optionnels puis de les interpréter afin de les afficher l'un après l'autre tout en ayant analysé le &lt;span style="font-style: italic;"&gt;*msg&lt;/span&gt; pour déterminer leurs emplacements. Bref, c'est beaucoup de travail pour pas grand chose. C'est là qu'interviennent les fonctions &lt;span style="font-style: italic;"&gt;vprintf&lt;/span&gt;.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;Quand vous utilisez les arguments optionnels, vous déclarez forcément une variable &lt;span style="font-style: italic;"&gt;va_list&lt;/span&gt;. Et la fonction &lt;span style="font-style: italic;"&gt;va_start()&lt;/span&gt; permet de peupler la variable &lt;span style="font-style: italic;"&gt;va_list&lt;/span&gt; avec les paramètres. Il se trouve que &lt;span style="font-style: italic;"&gt;vprintf&lt;/span&gt; réclame une variable de type &lt;span style="font-style: italic;"&gt;va_list&lt;/span&gt;.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Reprenons alors notre exemple en le complétant:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;static void&lt;/span&gt; my_log(&lt;span style="color: rgb(153, 0, 0);"&gt;const char&lt;/span&gt; *msg, ...) {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color: rgb(255, 255, 255);"&gt;  ..&lt;/span&gt;va_list va;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color: rgb(255, 255, 255);"&gt;..&lt;/span&gt;va_start(va, msg);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color: rgb(255, 255, 255);"&gt;..&lt;/span&gt;if (msg) {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color: rgb(255, 255, 255);"&gt;....&lt;/span&gt;vfprintf(stderr, msg, va);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color: rgb(255, 255, 255);"&gt;....&lt;/span&gt;fprintf(stderr, &lt;span style="color: rgb(255, 0, 0);"&gt;"&lt;span style="color: rgb(204, 51, 204);"&gt;\n&lt;/span&gt;"&lt;/span&gt;);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color: rgb(255, 255, 255);"&gt;..&lt;/span&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color: rgb(255, 255, 255);"&gt;..&lt;/span&gt;va_end(va);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="font-style: italic;"&gt;vfprintf&lt;/span&gt; va donc nous éviter un code monstrueux en exploitant directement la liste de paramètres. Ainsi notre fonction de "logging" (minimaliste) est terminée!&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20659215-3214686911839995314?l=sky13.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sky13.blogspot.com/feeds/3214686911839995314/comments/default' title='Publier les commentaires'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20659215&amp;postID=3214686911839995314&amp;isPopup=true' title='1 commentaires'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20659215/posts/default/3214686911839995314'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20659215/posts/default/3214686911839995314'/><link rel='alternate' type='text/html' href='http://sky13.blogspot.com/2007/07/un-systme-de-logging-en-c.html' title='Un système de &quot;logging&quot; en C'/><author><name>Sky13</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20659215.post-7173247730385947383</id><published>2007-06-29T17:23:00.000+02:00</published><updated>2007-07-02T15:19:25.952+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='programmation'/><title type='text'>Pseudo-polymorphisme en C</title><content type='html'>&lt;div style="text-align: justify;"&gt;&lt;span style=";font-family:verdana;font-size:100%;"  &gt;Mais kesako? Je ne suis pas là pour vous expliquer ce qu'est le polymorphisme. Tout programmeur en langage à objets (ou orienté objets) y a touché de près ou de loin. Mais tout l'intérêt de mon message réside dans le fait de faire du polymorphisme, mais sans objet!&lt;br /&gt;L'intérêt? Pourquoi pas? Tout ce qui est bon est à prendre. Il peut arriver d'en  dans certains cas d'en avoir besoin et de regretter de ne pas travailler en langage à objets. Alors je vais vous montrer une implémentation très simple du polymorphisme en langage C.&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=";font-family:verdana;font-size:100%;"  &gt;&lt;span style="font-weight: bold;font-size:130%;" &gt;Le langage C&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;div style="text-align: justify;"&gt;&lt;span style=";font-family:verdana;font-size:100%;"  &gt;Le langage C est tout sauf objet (c'est un langage impératif), c'est bien pour cela que le C++ a été inventé. Ainsi l'implémentation que je vais vous montrer atteint très vite ses limites. Mais dans des cas particuliers cela peut s'avérer très utile. En objet pour réaliser du polymorphisme il nous serait nécessaire de créer des classes et donc des objets. Voici les correspondances que l'on va faire :&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;span style=";font-family:verdana;font-size:100%;"  &gt;&lt;span style="font-style: italic;font-size:85%;" &gt;classe &gt; structure&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-style: italic;font-size:85%;" &gt;objet &gt; pointeur sur une variable déclarée comme étant une structure&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-style: italic;font-size:85%;" &gt;méthode &gt; référence dans la structure à une fonction&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-size:130%;" &gt;Cas en exemple&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;div style="text-align: justify;"&gt;&lt;span style=";font-family:verdana;font-size:100%;"  &gt;Comme exemple nous allons prendre un cas où il y a deux pseudo-objets, et chacun de ces pseudo-objet à une pseudo-méthode &lt;span style="font-style: italic;"&gt;print()&lt;/span&gt;. Nous voulons appeler celle-ci depuis un même tableau de ces pseudo-objets. Commençons par définir nos pseudo-classes.&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;span style=";font-family:verdana;font-size:100%;"  &gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-family:courier new;font-size:100%;"  &gt;typedef struct&lt;/span&gt;&lt;span style=";font-family:courier new;font-size:100%;"  &gt; myh_s {&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;div style="text-align: left;"&gt;&lt;span style=";font-family:verdana;font-size:100%;"  &gt;&lt;span style="color: rgb(153, 0, 0);font-family:courier new;font-size:100%;"  &gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=";font-family:verdana;font-size:100%;"  &gt;&lt;span style="color: rgb(153, 0, 0);font-family:courier new;font-size:100%;"  &gt; &lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 255, 255);font-family:verdana;font-size:100%;"  &gt;&lt;span style="font-weight: bold;font-family:courier new;font-size:100%;"  &gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 255, 255);font-family:verdana;font-size:100%;"  &gt;&lt;span style="font-weight: bold;font-family:courier new;font-size:100%;"  &gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style=";font-family:verdana;font-size:100%;"  &gt;&lt;span style="color: rgb(153, 0, 0);font-family:courier new;font-size:100%;"  &gt;void&lt;/span&gt;&lt;span style=";font-family:courier new;font-size:100%;"  &gt; (*print) &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);font-family:courier new;font-size:100%;"  &gt;(void);&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;span style="color: rgb(255, 255, 255);font-family:verdana;font-size:100%;"  &gt;&lt;span style="font-weight: bold;font-family:courier new;font-size:100%;"  &gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 255, 255);font-family:verdana;font-size:100%;"  &gt;&lt;span style="font-weight: bold;font-family:courier new;font-size:100%;"  &gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style=";font-family:verdana;font-size:100%;"  &gt;&lt;span style="color: rgb(153, 0, 0);font-family:courier new;font-size:100%;"  &gt;int&lt;/span&gt;&lt;span style=";font-family:courier new;font-size:100%;"  &gt; x;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;span style=";font-family:verdana;font-size:100%;"  &gt;&lt;span style=";font-family:courier new;font-size:100%;"  &gt;} myh_t;&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-weight: bold;font-family:courier new;font-size:100%;"  &gt;typedef struct&lt;/span&gt;&lt;span style=";font-family:courier new;font-size:100%;"  &gt; myb_s {&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 255, 255);font-family:verdana;font-size:100%;"  &gt;&lt;span style="font-weight: bold;font-family:courier new;font-size:100%;"  &gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 255, 255);font-family:verdana;font-size:100%;"  &gt;&lt;span style="font-weight: bold;font-family:courier new;font-size:100%;"  &gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style=";font-family:verdana;font-size:100%;"  &gt;&lt;span style="color: rgb(153, 0, 0);font-family:courier new;font-size:100%;"  &gt;void&lt;/span&gt;&lt;span style=";font-family:courier new;font-size:100%;"  &gt; (*print) &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);font-family:courier new;font-size:100%;"  &gt;(void);&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 255, 255);font-family:verdana;font-size:100%;"  &gt;&lt;span style="font-weight: bold;font-family:courier new;font-size:100%;"  &gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 255, 255);font-family:verdana;font-size:100%;"  &gt;&lt;span style="font-weight: bold;font-family:courier new;font-size:100%;"  &gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style=";font-family:verdana;font-size:100%;"  &gt;&lt;span style="color: rgb(153, 0, 0);font-family:courier new;font-size:100%;"  &gt;double&lt;/span&gt;&lt;span style=";font-family:courier new;font-size:100%;"  &gt; x;&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=";font-family:courier new;font-size:100%;"  &gt;} myb_t;&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(153, 153, 153);font-family:courier new;font-size:100%;"  &gt;/* Generic pseudo-class */&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-weight: bold;font-family:courier new;font-size:100%;"  &gt;typedef struct&lt;/span&gt;&lt;span style=";font-family:courier new;font-size:100%;"  &gt; gen_s {&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 255, 255);font-family:verdana;font-size:100%;"  &gt;&lt;span style="font-weight: bold;font-family:courier new;font-size:100%;"  &gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 255, 255);font-family:verdana;font-size:100%;"  &gt;&lt;span style="font-weight: bold;font-family:courier new;font-size:100%;"  &gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style=";font-family:verdana;font-size:100%;"  &gt;&lt;span style="color: rgb(153, 0, 0);font-family:courier new;font-size:100%;"  &gt;void&lt;/span&gt;&lt;span style=";font-family:courier new;font-size:100%;"  &gt; (*print) &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);font-family:courier new;font-size:100%;"  &gt;(void);&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=";font-family:courier new;font-size:100%;"  &gt;} gen_t;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;div style="text-align: justify;"&gt;&lt;span style=";font-family:verdana;font-size:100%;"  &gt;Notre exemple comportera deux pseudo-objets. Une pseudo-classe générique est nécessaire afin de pouvoir déclarer un tableau pour contenir nos pseudo-objets (une sorte de pseudo-héritage). Attention, il faut veiller à définir les pseudo-méthodes dans le même ordre partout! Il faut les définir au début de chaque structure. Les variables &lt;span style="color: rgb(153, 0, 0);"&gt;double&lt;/span&gt; et &lt;span style="color: rgb(153, 0, 0);"&gt;int&lt;/span&gt; sont là uniquement pour l'exemple.&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;span style=";font-family:verdana;font-size:100%;"  &gt;&lt;br /&gt;&lt;/span&gt;&lt;div style="text-align: justify;"&gt;&lt;span style=";font-family:verdana;font-size:100%;"  &gt;Maintenant que nous avons les structures, il faut définir les fonctions qui feront office de pseudo-méthode.&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;span style=";font-family:verdana;font-size:100%;"  &gt;&lt;br /&gt;&lt;span style=";font-family:courier new;font-size:100%;"  &gt;&lt;span style="color: rgb(153, 0, 0);"&gt;void&lt;/span&gt; print_hello(&lt;span style="color: rgb(153, 0, 0);"&gt;void&lt;/span&gt;) {&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 255, 255);font-family:verdana;font-size:100%;"  &gt;&lt;span style="font-weight: bold;font-family:courier new;font-size:100%;"  &gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 255, 255);font-family:verdana;font-size:100%;"  &gt;&lt;span style="font-weight: bold;font-family:courier new;font-size:100%;"  &gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style=";font-family:verdana;font-size:100%;"  &gt;&lt;span style=";font-family:courier new;font-size:100%;"  &gt;printf(&lt;span style="color: rgb(255, 0, 0);"&gt;"Hello Linuxfr users!&lt;span style="color: rgb(204, 51, 204);"&gt;\n&lt;/span&gt;"&lt;/span&gt;);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;void&lt;/span&gt; print_bye(&lt;span style="color: rgb(153, 0, 0);"&gt;void&lt;/span&gt;) {&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 255, 255);font-family:verdana;font-size:100%;"  &gt;&lt;span style="font-weight: bold;font-family:courier new;font-size:100%;"  &gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 255, 255);font-family:verdana;font-size:100%;"  &gt;&lt;span style="font-weight: bold;font-family:courier new;font-size:100%;"  &gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style=";font-family:verdana;font-size:100%;"  &gt;&lt;span style=";font-family:courier new;font-size:100%;"  &gt;printf(&lt;span style="color: rgb(255, 0, 0);"&gt;"Bye Linuxfr users&lt;span style="color: rgb(204, 51, 204);"&gt;!\n&lt;/span&gt;"&lt;/span&gt;);&lt;br /&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;div style="text-align: justify;"&gt;&lt;span style=";font-family:verdana;font-size:100%;"  &gt;Avant de s'attaquer à la fonction &lt;span style="font-style: italic;"&gt;main()&lt;/span&gt;, il est important de créer encore deux fonctions pour déclarer nos pseudo-objets en mémoire. Pour cela nous allons faire de l'allocation de mémoire dynamique avec &lt;span style="font-style: italic;"&gt;malloc()&lt;/span&gt;. Sans oublier d'assigner les références des fonctions à la pseudo-méthode de chaque pseudo-objet.&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;span style=";font-family:verdana;font-size:100%;"  &gt;&lt;br /&gt;&lt;span style=";font-family:courier new;font-size:100%;"  &gt;myh_t *new_h(&lt;span style="color: rgb(153, 0, 0);"&gt;void&lt;/span&gt;) {&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 255, 255);font-family:verdana;font-size:100%;"  &gt;&lt;span style="font-weight: bold;font-family:courier new;font-size:100%;"  &gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 255, 255);font-family:verdana;font-size:100%;"  &gt;&lt;span style="font-weight: bold;font-family:courier new;font-size:100%;"  &gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style=";font-family:verdana;font-size:100%;"  &gt;&lt;span style=";font-family:courier new;font-size:100%;"  &gt;myh_t *my;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 255, 255);font-family:verdana;font-size:100%;"  &gt;&lt;span style="font-weight: bold;font-family:courier new;font-size:100%;"  &gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 255, 255);font-family:verdana;font-size:100%;"  &gt;&lt;span style="font-weight: bold;font-family:courier new;font-size:100%;"  &gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style=";font-family:verdana;font-size:100%;"  &gt;&lt;span style=";font-family:courier new;font-size:100%;"  &gt;my = malloc(&lt;span style="font-weight: bold;"&gt;sizeof&lt;/span&gt;(myh_t));&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 255, 255);font-family:verdana;font-size:100%;"  &gt;&lt;span style="font-weight: bold;font-family:courier new;font-size:100%;"  &gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 255, 255);font-family:verdana;font-size:100%;"  &gt;&lt;span style="font-weight: bold;font-family:courier new;font-size:100%;"  &gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style=";font-family:verdana;font-size:100%;"  &gt;&lt;span style=";font-family:courier new;font-size:100%;"  &gt;my-&gt;print = print_hello;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 255, 255);font-family:verdana;font-size:100%;"  &gt;&lt;span style="font-weight: bold;font-family:courier new;font-size:100%;"  &gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 255, 255);font-family:verdana;font-size:100%;"  &gt;&lt;span style="font-weight: bold;font-family:courier new;font-size:100%;"  &gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style=";font-family:verdana;font-size:100%;"  &gt;&lt;span style=";font-family:courier new;font-size:100%;"  &gt;&lt;span style="font-weight: bold;"&gt;return&lt;/span&gt; my;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;myb_t *new_b(&lt;span style="color: rgb(153, 0, 0);"&gt;void&lt;/span&gt;) {&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 255, 255);font-family:verdana;font-size:100%;"  &gt;&lt;span style="font-weight: bold;font-family:courier new;font-size:100%;"  &gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 255, 255);font-family:verdana;font-size:100%;"  &gt;&lt;span style="font-weight: bold;font-family:courier new;font-size:100%;"  &gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style=";font-family:verdana;font-size:100%;"  &gt;&lt;span style=";font-family:courier new;font-size:100%;"  &gt;myb_t *my;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 255, 255);font-family:verdana;font-size:100%;"  &gt;&lt;span style="font-weight: bold;font-family:courier new;font-size:100%;"  &gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 255, 255);font-family:verdana;font-size:100%;"  &gt;&lt;span style="font-weight: bold;font-family:courier new;font-size:100%;"  &gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style=";font-family:verdana;font-size:100%;"  &gt;&lt;span style=";font-family:courier new;font-size:100%;"  &gt;my = malloc(&lt;span style="font-weight: bold;"&gt;sizeof&lt;/span&gt;(myb_t));&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 255, 255);font-family:verdana;font-size:100%;"  &gt;&lt;span style="font-weight: bold;font-family:courier new;font-size:100%;"  &gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 255, 255);font-family:verdana;font-size:100%;"  &gt;&lt;span style="font-weight: bold;font-family:courier new;font-size:100%;"  &gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style=";font-family:verdana;font-size:100%;"  &gt;&lt;span style=";font-family:courier new;font-size:100%;"  &gt;my-&gt;print = print_bye;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 255, 255);font-family:verdana;font-size:100%;"  &gt;&lt;span style="font-weight: bold;font-family:courier new;font-size:100%;"  &gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 255, 255);font-family:verdana;font-size:100%;"  &gt;&lt;span style="font-weight: bold;font-family:courier new;font-size:100%;"  &gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style=";font-family:verdana;font-size:100%;"  &gt;&lt;span style=";font-family:courier new;font-size:100%;"  &gt;&lt;span style="font-weight: bold;"&gt;return&lt;/span&gt; my;&lt;br /&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;div style="text-align: justify;"&gt;&lt;span style=";font-family:verdana;font-size:100%;"  &gt;Bien sûr, il faudrait tester les variables afin de s'assurer que l'allocation à pu s'effectuer avec succès. Néanmoins pour cet exemple ce n'est pas fatal. A vous de faire les choses le plus correctement possible dans votre implémentation.&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=";font-family:verdana;font-size:100%;"  &gt;A l'aide de ce travail, notre &lt;span style="font-style: italic;"&gt;main()&lt;/span&gt; se présente un peu comme un langage à objets et le pseudo-polymorphisme peut agir dans la boucle &lt;span style="font-weight: bold;"&gt;for&lt;/span&gt;.&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;span style=";font-family:verdana;font-size:100%;"  &gt;&lt;br /&gt;&lt;span style=";font-family:courier new;font-size:100%;"  &gt;&lt;span style="color: rgb(153, 0, 0);"&gt;int&lt;/span&gt; main(&lt;span style="color: rgb(153, 0, 0);"&gt;void&lt;/span&gt;) {&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 255, 255);font-family:verdana;font-size:100%;"  &gt;&lt;span style="font-weight: bold;font-family:courier new;font-size:100%;"  &gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 255, 255);font-family:verdana;font-size:100%;"  &gt;&lt;span style="font-weight: bold;font-family:courier new;font-size:100%;"  &gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style=";font-family:verdana;font-size:100%;"  &gt;&lt;span style=";font-family:courier new;font-size:100%;"  &gt;&lt;span style="color: rgb(153, 0, 0);"&gt;int&lt;/span&gt; i;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 255, 255);font-family:verdana;font-size:100%;"  &gt;&lt;span style="font-weight: bold;font-family:courier new;font-size:100%;"  &gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 255, 255);font-family:verdana;font-size:100%;"  &gt;&lt;span style="font-weight: bold;font-family:courier new;font-size:100%;"  &gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style=";font-family:verdana;font-size:100%;"  &gt;&lt;span style=";font-family:courier new;font-size:100%;"  &gt;myh_t *my_hello;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 255, 255);font-family:verdana;font-size:100%;"  &gt;&lt;span style="font-weight: bold;font-family:courier new;font-size:100%;"  &gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 255, 255);font-family:verdana;font-size:100%;"  &gt;&lt;span style="font-weight: bold;font-family:courier new;font-size:100%;"  &gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style=";font-family:verdana;font-size:100%;"  &gt;&lt;span style=";font-family:courier new;font-size:100%;"  &gt;myb_t *my_bye;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 255, 255);font-family:verdana;font-size:100%;"  &gt;&lt;span style="font-weight: bold;font-family:courier new;font-size:100%;"  &gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 255, 255);font-family:verdana;font-size:100%;"  &gt;&lt;span style="font-weight: bold;font-family:courier new;font-size:100%;"  &gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style=";font-family:verdana;font-size:100%;"  &gt;&lt;span style=";font-family:courier new;font-size:100%;"  &gt;gen_t *my[&lt;span style="color: rgb(51, 51, 255);"&gt;2&lt;/span&gt;];&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 255, 255);font-family:verdana;font-size:100%;"  &gt;&lt;span style="font-weight: bold;font-family:courier new;font-size:100%;"  &gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 255, 255);font-family:verdana;font-size:100%;"  &gt;&lt;span style="font-weight: bold;font-family:courier new;font-size:100%;"  &gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style=";font-family:verdana;font-size:100%;"  &gt;&lt;span style=";font-family:courier new;font-size:100%;"  &gt;&lt;span style="color: rgb(153, 153, 153);"&gt;/* Create pseudo-objects */&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 255, 255);font-family:verdana;font-size:100%;"  &gt;&lt;span style="font-weight: bold;font-family:courier new;font-size:100%;"  &gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 255, 255);font-family:verdana;font-size:100%;"  &gt;&lt;span style="font-weight: bold;font-family:courier new;font-size:100%;"  &gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style=";font-family:verdana;font-size:100%;"  &gt;&lt;span style=";font-family:courier new;font-size:100%;"  &gt;my_hello = new_h();&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 255, 255);font-family:verdana;font-size:100%;"  &gt;&lt;span style="font-weight: bold;font-family:courier new;font-size:100%;"  &gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 255, 255);font-family:verdana;font-size:100%;"  &gt;&lt;span style="font-weight: bold;font-family:courier new;font-size:100%;"  &gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style=";font-family:verdana;font-size:100%;"  &gt;&lt;span style=";font-family:courier new;font-size:100%;"  &gt;my_bye = new_b();&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 255, 255);font-family:verdana;font-size:100%;"  &gt;&lt;span style="font-weight: bold;font-family:courier new;font-size:100%;"  &gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 255, 255);font-family:verdana;font-size:100%;"  &gt;&lt;span style="font-weight: bold;font-family:courier new;font-size:100%;"  &gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style=";font-family:verdana;font-size:100%;"  &gt;&lt;span style=";font-family:courier new;font-size:100%;"  &gt;m&lt;/span&gt;&lt;/span&gt;&lt;span style=";font-family:verdana;font-size:100%;"  &gt;&lt;span style=";font-family:courier new;font-size:100%;"  &gt;y[&lt;span style="color: rgb(51, 51, 255);"&gt;0&lt;/span&gt;] = (gen_t *)my_hello;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 255, 255);font-family:verdana;font-size:100%;"  &gt;&lt;span style="font-weight: bold;font-family:courier new;font-size:100%;"  &gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 255, 255);font-family:verdana;font-size:100%;"  &gt;&lt;span style="font-weight: bold;font-family:courier new;font-size:100%;"  &gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style=";font-family:verdana;font-size:100%;"  &gt;&lt;span style=";font-family:courier new;font-size:100%;"  &gt;my[&lt;span style="color: rgb(51, 51, 255);"&gt;1&lt;/span&gt;] = (gen_t *)my_bye;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 255, 255);font-family:verdana;font-size:100%;"  &gt;&lt;span style="font-weight: bold;font-family:courier new;font-size:100%;"  &gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 255, 255);font-family:verdana;font-size:100%;"  &gt;&lt;span style="font-weight: bold;font-family:courier new;font-size:100%;"  &gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style=";font-family:verdana;font-size:100%;"  &gt;&lt;span style=";font-family:courier new;font-size:100%;"  &gt;&lt;span style="color: rgb(153, 153, 153);"&gt;/* Use pseudo-objects */&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 255, 255);font-family:verdana;font-size:100%;"  &gt;&lt;span style="font-weight: bold;font-family:courier new;font-size:100%;"  &gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 255, 255);font-family:verdana;font-size:100%;"  &gt;&lt;span style="font-weight: bold;font-family:courier new;font-size:100%;"  &gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style=";font-family:verdana;font-size:100%;"  &gt;&lt;span style=";font-family:courier new;font-size:100%;"  &gt;&lt;span style="font-weight: bold;"&gt;for&lt;/span&gt; (i = &lt;span style="color: rgb(51, 51, 255);"&gt;0&lt;/span&gt;; i &lt; &lt;span style="color: rgb(51, 51, 255);"&gt;2&lt;/span&gt;; i++)&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 255, 255);font-family:verdana;font-size:100%;"  &gt;&lt;span style="font-weight: bold;font-family:courier new;font-size:100%;"  &gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 255, 255);font-family:verdana;font-size:100%;"  &gt;&lt;span style="font-weight: bold;font-family:courier new;font-size:100%;"  &gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 255, 255);font-family:verdana;font-size:100%;"  &gt;&lt;span style="font-weight: bold;font-family:courier new;font-size:100%;"  &gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 255, 255);font-family:verdana;font-size:100%;"  &gt;&lt;span style="font-weight: bold;font-family:courier new;font-size:100%;"  &gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style=";font-family:verdana;font-size:100%;"  &gt;&lt;span style=";font-family:courier new;font-size:100%;"  &gt;my[i]-&gt;print();&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 255, 255);font-family:verdana;font-size:100%;"  &gt;&lt;span style="font-weight: bold;font-family:courier new;font-size:100%;"  &gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 255, 255);font-family:verdana;font-size:100%;"  &gt;&lt;span style="font-weight: bold;font-family:courier new;font-size:100%;"  &gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style=";font-family:verdana;font-size:100%;"  &gt;&lt;span style=";font-family:courier new;font-size:100%;"  &gt;&lt;span style="color: rgb(153, 153, 153);"&gt;/* Delete pseudo-objects */&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 255, 255);font-family:verdana;font-size:100%;"  &gt;&lt;span style="font-weight: bold;font-family:courier new;font-size:100%;"  &gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 255, 255);font-family:verdana;font-size:100%;"  &gt;&lt;span style="font-weight: bold;font-family:courier new;font-size:100%;"  &gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style=";font-family:verdana;font-size:100%;"  &gt;&lt;span style=";font-family:courier new;font-size:100%;"  &gt;free(my_hello);&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 255, 255);font-family:verdana;font-size:100%;"  &gt;&lt;span style="font-weight: bold;font-family:courier new;font-size:100%;"  &gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 255, 255);font-family:verdana;font-size:100%;"  &gt;&lt;span style="font-weight: bold;font-family:courier new;font-size:100%;"  &gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style=";font-family:verdana;font-size:100%;"  &gt;&lt;span style=";font-family:courier new;font-size:100%;"  &gt;free(my_bye);&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 255, 255);font-family:verdana;font-size:100%;"  &gt;&lt;span style="font-weight: bold;font-family:courier new;font-size:100%;"  &gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 255, 255);font-family:verdana;font-size:100%;"  &gt;&lt;span style="font-weight: bold;font-family:courier new;font-size:100%;"  &gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style=";font-family:verdana;font-size:100%;"  &gt;&lt;span style=";font-family:courier new;font-size:100%;"  &gt;&lt;span style="font-weight: bold;"&gt;return&lt;/span&gt; &lt;span style="color: rgb(51, 51, 255);"&gt;0&lt;/span&gt;;&lt;br /&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:verdana;"&gt;La sortie du programme correspond donc à:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;Hello Linuxfr users!&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;Bye Linuxfr users!&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=";font-family:verdana;font-size:100%;"  &gt;Je vous conseil néanmoins de ne pas abuser de ce genre "d'astuce", car il est bien clair que le C n'est pas un langage fait pour l'objet.&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20659215-7173247730385947383?l=sky13.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sky13.blogspot.com/feeds/7173247730385947383/comments/default' title='Publier les commentaires'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20659215&amp;postID=7173247730385947383&amp;isPopup=true' title='0 commentaires'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20659215/posts/default/7173247730385947383'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20659215/posts/default/7173247730385947383'/><link rel='alternate' type='text/html' href='http://sky13.blogspot.com/2007/06/pseudo-polymorphisme-en-c.html' title='Pseudo-polymorphisme en C'/><author><name>Sky13</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20659215.post-113665355517484592</id><published>2006-01-07T17:58:00.000+01:00</published><updated>2007-07-01T15:18:13.828+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='jeu'/><title type='text'>X-Wing Alliance &amp; NVidia ...</title><content type='html'>&lt;div style="text-align: justify;"&gt;Ce message a pour but de vous expliquer comment régler vos éventuels problèmes avec le jeu X-Wing Alliance. Ce superbe jeu est en fait le dernier vrai simulateur spatial StarWars de LucasArts. Ce qu'on entend par simulateur spatial, c'est le fait de piloter des vaisseaux de manière plus évoluée qu'un jeu d'arcade. Il faut bien sûr aimer les 50 combinaisons de touches du clavier et les missions périlleuses dans le monde imaginaire de George Lucas.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-weight: bold;"&gt;Avant-propos&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;div style="text-align: justify;"&gt;Mais je ne suis pas là pour vous faire l'histoire des simulateurs spatiaux, mais pour vous expliquer le problème que j'ai eu pour y rejouer dans de bonnes conditions. Avant cela il faut savoir que ce simulateur commence à se faire vieux (1999) et la société LucasArts ne semble pas prête d'en resortir un nouveau. La tendance actuelle étant malheuresement aux jeux d'arcades trop facilement abordable.&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;De ce fait j'ai voulus me replonger dans cette simulation, et quand bien même je l'avais installé, patché, configuré et exécuté sans défaut, un problème pas si majeur que ça mais néanmoins désagréable à la vue, a tout de suite coupé mes ardeurs de pilote.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-weight: bold;"&gt;Un problème de contre-mesures, vous dîtes?&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;div style="text-align: justify;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://gamesover.my-underworld.net/gamesover.net/xwa.png"&gt;&lt;img style="margin: 0pt 0pt 10px 10px; float: right; cursor: pointer; width: 200px;" src="http://gamesover.my-underworld.net/gamesover.net/xwa.png" alt="" border="0" /&gt;&lt;/a&gt;Mais non voyons, laissons les contre-mesures où elles sont, d'ailleur, la première mission ne permet pas d'en équiper notre vaisseau (le fameux YT-1300). Le problème est relatif aux graphismes qui sont désagréables à l'oeil. Pour deux raisons, la première est que les textes sont à la limite du lisible (surtout en pleine mission), non pas qu'ils soient trop petits, mais plutôt qu'ils ne sont pas rendus correctement. La seconde est que le mip-mapping ainsi que le bilinear filtering ne sont pas du tout activé. Je ne suis pas là pour vous expliquer les termes techniques, google peut très bien s'en charger pour vous. Par contre, la photo ci-contre devrait être assez explicite.  Peut-être que pour vous ce n'est pas un problème? Dans ce cas je ne vous oblige pas à lire le reste, par contre pour moi c'en est un et je ne peux pas m'empêcher de chercher par tous les moyens possibles pour le corriger et rejouer dans des conditions au moins aussi bonnes qu'à l'époque. Avant de m'avancer plus loin dans le sujet, je souhaiterais qu'en même vous faire part de la configuration matériel et logiciel de l'ordinateur sur lequel "je pilote".&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-style: italic;"&gt;Matériels&lt;/span&gt; : Pentium 3 1Ghz/133, 512 Mo RAM, GeForce 4 4800 SE&lt;br /&gt;&lt;span style="font-style: italic;"&gt;Logiciels&lt;/span&gt; : X-Wing Alliance 2.02, Windows XP Pro SP2, ForceWare 81.98&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Comme vous pouvez le voir, il n'y a rien d'extraordinaire, un matériel relativement vieux certe, mais pas plus que le jeu. Et en ce qui concerne les versions logiciels, se sont les plus à jour au moment où j'ai écris ces lignes.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-weight: bold;"&gt;Attention aux tirs croisés!&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;Ma démarche était très simple, d'abord il fallait m'assurer que je n'étais pas le seul avec ce problème. J'ai donc fais de multiples recherches sur le web mais sans grand succès. Personne ne semblait se plaindre et pourtant il existe de nombreux sites et fans des séries de jeux X-Wing.  J'ai donc tenté en vain de trouver une solution en réinstallant les drivers de la carte graphique, en réinstallant les drivers du chipset de la carte mère. Mais rien n'y faisait. Même que ça m'a apporté plus de problèmes que de solutions. Des problèmes que je n'aborderais pas ici. J'ai alors tenté le tout pour le tout et me suis reconnecté sous mon installation Linux, en espérant que WINE puisse me sortir de cette bagarre logiciel.&lt;br /&gt;Pour les moins connaisseurs d'entre vous, WINE n'est pas un bon verre de vin chaud, mais plutôt une API libre (&lt;a href="http://www.winehq.org/"&gt;hwww.winehq.org&lt;/a&gt;) qui permet d'exécuter des logiciels sous Linux, qui originellement sont fait pour Windows. J'ai donc remis à niveau l'API, tenté de faire fonctionner le jeu et je me suis confronté à un nouveau problème. X-Wing Alliance ne veut pas s'exécuter s'il n'y a pas de joystick connecté à l'ordinateur. Avant de trouver la solution pour le faire reconnaître par WINE, j'en profite pour parcourir les forums francophones comme anglophones afin de poser mes questions. Quelques utilisateurs me répondent qu'ils n'ont pas de problème, l'un d'eux me dit qu'il confirme qu'il a aussi de mauvais graphismes mais avec une GeForce 4400 (équivalente à la mienne). Néanmoins personne ne connait vraiment la cause.&lt;br /&gt;Sur un forum anglophone une personne fait des tests avec sa GeForce 5600, et n'a aucun soucis particulier. Et d'ailleur, tous les utilisateurs de carte graphique ATI ont des graphismes sans la moindre bavure. D'où le titre de ce message. Pendant ce temps, je continue mes investigations avec WINE, je trouve le moyen de lui faire démarrer le jeu, et quand je pense avoir résolu, celui-ci ne veut pas exécuter la partie. WINE étant toujours en plein développement, on ne peut en aucun cas lui reprocher ce genre de faiblesse. Et l'évolution de la compatibilité du jeu peut être constamment suivie à &lt;a href="http://appdb.winehq.org/appview.php?versionId=2916"&gt;cette adresse&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-weight: bold;"&gt;Enfin une balise hyperespace!&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;Les forums reste les meilleurs moyens de s'en sortir. Tout ses tests réalisés par les autre joueurs prouvaient quelque chose. Les GeForces de la série 4 posent plus de problème que ceux de la série 5 et plus. Un seul problème persistait chez tout le monde, les textes resortent mal en haute définition comme 1280x1024 par exemple. Mais cela concernant tout le monde (ou tout du moins tous les utilisateurs de GeForce) que LucasArts a mis à disposition les moyens de le corriger. D'ailleur voici l'URI en question chez &lt;a href="http://www.lucasfiles.com/?s=&amp;action=category&amp;amp;id=107"&gt;LucasFiles&lt;/a&gt;. Et pour être plus précis, le problème des caractères se manifeste avec l'utilisation de l'anticrénelage (antialiasing) et de l'anisotropie.&lt;br /&gt;&lt;br /&gt;Mais revenons à nos GeForce 4. Le moyen de s'en résoudre est simple, mais ennuyeux à la fois. Il faut tout simplement utiliser de vieux pilotes NVidia. Malheuresement la série de pilote 81.nn n'apporte que des ennuies avec XwA, par contre, les 66.93 fonctionne à merveille. Mais cela peut poser bien d'autre problèmes au niveaux de certains jeux videos qui réclament toujours, ce qu'il y a de plus récent.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://gamesover.my-underworld.net/gamesover.net/xwa_f.png"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 200px;" src="http://gamesover.my-underworld.net/gamesover.net/xwa_f.png" alt="" border="0" /&gt;&lt;/a&gt;Je ne peux que vous conseillez de garder les anciens le temps d'y jouer jusqu'à ce que vous en soyez dégouté, pour ensuite remettre tout votre système à jour dans les cas où les dernières versions seraient indispensable. Et si vous regardez la copie d'écran ci-contre, peut-être ne verrez-vous pas de quoi sauter au plafond, mais n'oublions rien, le jeu est vieux et la simulation reste sont point le plus fort, suffisamment fort pour vous faire oublier son âge.&lt;br /&gt;&lt;br /&gt;Je vous remercie de m'avoir lu, j'ai été, peut-être, un peu long, mais ça m'a fait plaisir. Et je n'ai pas été plus long que le temps qu'il m'a fallut à comprendre d'où vennait la faille. Car je ne vous ai pas tout dis, comme par exemple, que j'ai tenté de forcer l'installation des vieux pilotes DirectX 6. Mais c'est une autre histoire que je ne ferais pas partager ici.&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20659215-113665355517484592?l=sky13.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sky13.blogspot.com/feeds/113665355517484592/comments/default' title='Publier les commentaires'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20659215&amp;postID=113665355517484592&amp;isPopup=true' title='5 commentaires'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20659215/posts/default/113665355517484592'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20659215/posts/default/113665355517484592'/><link rel='alternate' type='text/html' href='http://sky13.blogspot.com/2006/01/x-wing-alliance-nvidia.html' title='X-Wing Alliance &amp; NVidia ...'/><author><name>Sky13</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>5</thr:total></entry></feed>
