<html><body><div style="color:#000; background-color:#fff; font-family:times new roman, new york, times, serif;font-size:12pt"><div><span style="font-weight: bold;">Hi guys,</span></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: times new roman,new york,times,serif; background-color: transparent; font-style: normal;"><span style="font-weight: bold;">I try to writte a small clock application in C. I have 3 files yet, </span><span>functions.h</span><span style="font-weight: bold;">, </span><span>functions.c</span><span style="font-weight: bold;">, </span><span>main.c</span><span style="font-weight: bold;">. I'm using a structure wich contains a </span><span>cairo_t</span><span style="font-weight: bold;"> and a </span><span>cairo_surface_t</span><span style="font-weight: bold;"> that I need to update during the running of the application. For having this I'm using a structure defined in </span><span>function.h</span><span
 style="font-weight: bold;">, I'm a little suspicious about how I use this st</span><span style="font-weight: bold;">ructure, I do some cast ( </span><span>(*_mc)</span><span style="font-weight: bold;"> ) but I'm not sure that's well written, (I never written something so funky...), could you just take a look and told me if it's correct. gcc doesn't complains, and I don't get any runtime error, so I'm just looking for a critic or an advice.</span></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: times new roman,new york,times,serif; background-color: transparent; font-style: normal;"><span style="font-weight: bold;"><br></span></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: times new roman,new york,times,serif; background-color: transparent; font-style: normal;"><span style="font-weight: bold;"> </span><span>functions.h</span><span style="font-weight: bold;"> has :</span></div><div><br></div><div style="color:
 rgb(0, 0, 0); font-size: 16px; font-family: times new roman,new york,times,serif; background-color: transparent; font-style: normal;"><...></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: times new roman,new york,times,serif; background-color: transparent; font-style: normal;">typedef struct clockStruc{<br>        cairo_t                 *c;<br>        cairo_surface_t         *s;<br><br>}CLOCKSTRUC;<br></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: times new roman,new york,times,serif; background-color: transparent; font-style: normal;"><...></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: times new roman,new york,times,serif; background-color: transparent; font-style: normal;"><br></div><div
 style="color: rgb(0, 0, 0); font-size: 16px; font-family: times new roman,new york,times,serif; background-color: transparent; font-style: normal;">functions.c <span style="font-weight: bold;">has :</span></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: times new roman,new york,times,serif; background-color: transparent; font-style: normal;"><br></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: times new roman,new york,times,serif; background-color: transparent; font-style: normal;"><...></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: times new roman,new york,times,serif; background-color: transparent; font-style: normal;">#include<cairo.h><br>#include<cairo-xlib.h><br>#include<time.h><br></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: times new roman,new york,times,serif; background-color: transparent; font-style:
 normal;">#include"functions.h"</div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: times new roman,new york,times,serif; background-color: transparent; font-style: normal;"><...></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: times new roman,new york,times,serif; background-color: transparent; font-style: normal;"><br></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: times new roman,new york,times,serif; background-color: transparent; font-style: normal;">void cairoClock(<span style="color: rgb(255, 0, 0);">CLOCKSTRUC *_mc</span>, <...> , int _x, int _y, int _sizex, int _sizey){</div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: times new roman,new york,times,serif; background-color: transparent; font-style: normal;">        <...><br></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: times new roman,new
 york,times,serif; background-color: transparent; font-style: normal;">        <span style="color: rgb(255, 0, 0);">(* _mc)</span>.s=cairo_xlib_surface_create(_dpy, wpnl, DefaultVisual(_dpy, 0), _sizex, _sizey);<br>        (* _mc).c=cairo_create((*_mc).s);<br><br>        cairo_rectangle((*_mc).c,0,0,_sizex,_sizey);<br>        cairo_set_source_rgba((*_mc).c, 0.5, 0., 0., 1.); // nicoo : rouge, temporaire....<br>        cairo_fill((*_mc).c);<br>}</div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: times new roman,new york,times,serif; background-color: transparent; font-style: normal;"><br></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: times new roman,new york,times,serif; background-color: transparent; font-style: normal;"><...></div><div
 style="color: rgb(0, 0, 0); font-size: 16px; font-family: times new roman,new york,times,serif; background-color: transparent; font-style: normal;"><br></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: times new roman,new york,times,serif; background-color: transparent; font-style: normal;"><span><span>main.c <span style="font-weight: bold;">has :</span></span></span></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: times new roman,new york,times,serif; background-color: transparent; font-style: normal;"><br></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: times new roman,new york,times,serif; background-color: transparent; font-style: normal;"><...><br></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: times new roman,new york,times,serif; background-color: transparent; font-style: normal;">#include"functions.h"</div><div style="color: rgb(0, 0, 0); font-size: 16px;
 font-family: times new roman,new york,times,serif; background-color: transparent; font-style: normal;"><...></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: times new roman,new york,times,serif; background-color: transparent; font-style: normal;"><br></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: times new roman,new york,times,serif; background-color: transparent; font-style: normal;">int main(int argc, char *argv[]){</div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: times new roman,new york,times,serif; background-color: transparent; font-style: normal;">        <...><br></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: times new roman,new york,times,serif; background-color: transparent; font-style: normal;">        <span style="color: rgb(255, 0, 0);">CLOCKSTRUC myClock</span>;<br></div><div
 style="color: rgb(0, 0, 0); font-size: 16px; font-family: times new roman,new york,times,serif; background-color: transparent; font-style: normal;">        <...><br></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: times new roman,new york,times,serif; background-color: transparent; font-style: normal;">        cairoClock(<span style="color: rgb(255, 0, 0);">&myClock</span>, dpy,scr,panelv,5,5,BAR2X-10,34);</div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: times new roman,new york,times,serif; background-color: transparent; font-style: normal;">        <...></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: times new roman,new york,times,serif; background-color: transparent; font-style: normal;">}</div></div></body></html>