Erreur de Segmentation

Résolu
cs_sebman Messages postés 37 Date d'inscription mercredi 29 mai 2002 Statut Membre Dernière intervention 11 décembre 2010 - 9 déc. 2010 à 11:22
cptpingu Messages postés 3837 Date d'inscription dimanche 12 décembre 2004 Statut Modérateur Dernière intervention 28 mars 2023 - 11 déc. 2010 à 13:01
Bonjour à tous

Alors voilà, pour apprendre à programmer, j'ai pomper un code source que j'ai un peu modifier.

Le programme initial servait à convertir la différence entre 2 dates en jours en Années, Mois, Secondes,...

Le but du programme final est une sorte de planning.

Au lieux de travailler en hebdomadaire (5 jours ouvrables et un week-end), je travaille en régime cyclique à savoir que sur 6 jours j'en travaille 4, les 2 autres étant en repos, et cela indéfiniment.

J'ai modifier le programme initial en mettant un "modulo" sur la division de la difference entre les 2 dates converties en jours.
Le résultat me donne le numéro de jour lequel est converti en chaine de caractères

Lorsque je compile mon programme: (je suis sous linux)

$ gcc `pkg-config --libs --cflags gtk+-2.0` monprog.c _o monprog

Je n'obtient pas d'erreur, mais lorsque je l'execute:

Erreur de Segmentation

Je pense que mon erreur est entre les 2 grosses lignes mise en commentaire

Merci pour toute aide !!!

Le code source:


#include <gtk/gtk.h> /* l'interface */
#include <time.h> /* pour time, mktime ... */
#include <stdio.h>
#include <math.h> /* pour floor */
#include /* pour sleep */

// la fenêtre
GtkWidget *f;
// la boite verticale
GtkWidget *v;
// la boite horizontale
GtkWidget *h;
// la table
GtkWidget *t;
// les combobox
GtkWidget *c[3];
// les spinbox
GtkWidget *s[2];
// les labels
GtkWidget *e[10];
//le bouton
GtkWidget *b;


char * mois[] = {"Janvier" , "Février", "Mars" , "Avril", "Mai" ,
"Juin" , "Juillet" , "Août" , "Septembre" , "Octobre" ,
"Novembre" , "Décembre"};

char *ages[] = {"secondes" , "minutes" , "° Jour" ,
"jours" , "mois"};
struct tm *naissance;
int choixMoisPrecedent;

/* les protoypes */
int init();
gboolean onFerme (GtkObject *w,gpointer d);
int traitement ();
int modificationComboJour (int indiceMois);

int
main(int argc, char **argv)
{
GtkAdjustment *g;
GtkTooltips *tt;
gint i;
gchar *ch;

gtk_init (&argc, &argv);

tt = gtk_tooltips_new ();
gtk_tooltips_enable (tt);
f = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_resizable (GTK_WINDOW(f), 0);

v = gtk_vbox_new (FALSE, 3);
gtk_box_set_spacing (GTK_BOX(v), 0);
gtk_container_add (GTK_CONTAINER(f), v);
//
/* première ligne */
//
h = gtk_hbox_new (FALSE, 5);
gtk_box_set_spacing (GTK_BOX(h), 0);
gtk_box_pack_start (GTK_BOX(v), h, 1, 1, 0);
/* Les combobox */
for (i = 0;i < 3;i++)
{
c[i] = gtk_combo_box_new ();
gtk_box_pack_start (GTK_BOX(h), c[i], 1, 1, 0);
}
//
/* Les spinbuttons */
g = (GtkAdjustment *) gtk_adjustment_new(0.0, 0.0, 23.0, 1.0, 4.0, 0.0);
s[0]= gtk_spin_button_new(g, 0.0, 0);
gtk_spin_button_set_value(GTK_SPIN_BUTTON(s[0]),08.0);
gtk_editable_set_editable(GTK_EDITABLE(s[0]), 0);
gtk_box_pack_start_defaults(GTK_BOX(h), s[0]);
gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), s[0],
"Réglage de l'heure",
"");
//
g = (GtkAdjustment *) gtk_adjustment_new(0.0, 0.0, 59, 1.0, 5.0, 0.0);
s[1]= gtk_spin_button_new(g, 0.0, 0);
gtk_spin_button_set_value(GTK_SPIN_BUTTON(s[1]),45.0);
gtk_editable_set_editable(GTK_EDITABLE(s[1]), 0);
gtk_box_pack_start_defaults(GTK_BOX(h), s[1]);
gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), s[1],
"Réglage des minutes",
"");
//
/* deuxième ligne */
//
t = gtk_table_new(4, 2, FALSE);
gtk_table_set_col_spacings(GTK_TABLE(t),10);
gtk_table_set_row_spacings(GTK_TABLE(t),10);
gtk_box_pack_start(GTK_BOX(v), t, 1, 1, 0);
for(i = 0;i < 10;i++)
{
e[i] = gtk_label_new(NULL);
ch = g_strdup_printf(" %s ", ages[i]);
gtk_label_set_markup(GTK_LABEL(e[i]), ch);
g_free(ch);
gtk_table_attach(GTK_TABLE(t), e[i],
(int) 1-(i/5), (int) 2-(i/5),
(int) (i%5), (int) (i%5)+1,
GTK_FILL | GTK_EXPAND,
GTK_FILL | GTK_EXPAND,
0, 0);
// on aligne à droite pour la 1re colonne à gauche pour l'autre
gtk_misc_set_alignment(GTK_MISC(e[i]), (int) (i/5), 0.5);
}
//
/* troisième ligne */
//
b = gtk_button_new_with_label("Quitter");
gtk_box_pack_start_defaults(GTK_BOX(v), b);
gtk_signal_connect(GTK_OBJECT(b), "clicked", (GtkSignalFunc) onFerme, NULL);
gtk_signal_connect(GTK_OBJECT(f), "destroy", (GtkSignalFunc) onFerme, NULL);

gtk_widget_show_all(f);

init();
traitement();
gtk_timeout_add(300, traitement, NULL);
gtk_main();

return 0;
}

int init () {
GtkListStore *l;
GtkTreeIter iter;
GtkCellRenderer *renderer;

gint i;
time_t n;

//
/* 1re combobox */
//
l = gtk_list_store_new(1, GTK_TYPE_INT);
gtk_combo_box_set_model(GTK_COMBO_BOX(c[0]), GTK_TREE_MODEL(l));
//
renderer = gtk_cell_renderer_text_new();
gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(c[0]), renderer, FALSE);
gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(c[0]), renderer, "text", 0, NULL);
//
for(i = 0;i < 30;i++) {
gtk_list_store_append(l, &iter);
gtk_list_store_set(l, &iter, 0, i+1, -1);
}
//
/* Deuxième combobox */
//
l = gtk_list_store_new(1, GTK_TYPE_STRING);
gtk_combo_box_set_model(GTK_COMBO_BOX(c[1]), GTK_TREE_MODEL(l));
//
renderer = gtk_cell_renderer_text_new();
gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(c[1]), renderer, FALSE);
gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(c[1]), renderer, "text", 0, NULL);
//
for(i = 0;i < 12;i++) {
gtk_list_store_append(l, &iter);
gtk_list_store_set(l, &iter, 0, mois[i], -1);
}
//
/* Troisième combobox */
//
l = gtk_list_store_new(1, GTK_TYPE_INT);
gtk_combo_box_set_model(GTK_COMBO_BOX(c[2]), GTK_TREE_MODEL(l));
//
renderer = gtk_cell_renderer_text_new();
gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(c[2]), renderer, FALSE);
gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(c[2]), renderer, "text", 0, NULL);
//
for(i = 0;i < 131;i++) {
gtk_list_store_append(l, &iter);
gtk_list_store_set(l, &iter, 0, i+1900, -1);
}

gtk_combo_box_set_active(GTK_COMBO_BOX(c[0]), 17);
gtk_combo_box_set_active(GTK_COMBO_BOX(c[1]), 4);
gtk_combo_box_set_active(GTK_COMBO_BOX(c[2]), 76);

/*
intialisation à la date
de naissance de Sacha
*/
time(&n);
naissance = localtime(&n);
/* naissance->tm_year = 100;
naissance->tm_mon = 1;// c'est bien en fait le mois de juin...
naissance->tm_mday = 1;
naissance->tm_hour = 8;
naissance->tm_min = 45;
naissance->tm_sec = 0;
*/
return 0;
}


gboolean onFerme (GtkObject *w,gpointer d) {
gtk_main_quit();
return 0;
}


int modificationComboJour (int indiceMois) {
GtkListStore *l;
GtkTreeIter iter;
GtkCellRenderer *renderer;

char *ch;
int i,iactif,choix;
int jourFin;
jourFin = 30;

//je récupère l'indice actif pour le réappliquer à la fin
iactif = gtk_combo_box_get_active(GTK_COMBO_BOX(c[0]));

l = GTK_LIST_STORE(gtk_combo_box_get_model(GTK_COMBO_BOX(c[0])));
gtk_list_store_clear(l);

// maintenant on ajoute au besoin :
if (indiceMois 0 || indiceMois 2 || indiceMois == 4 || indiceMois == 6) jourFin=31;
if (indiceMois 7 || indiceMois 9 || indiceMois == 11) jourFin=31;
// à faire : traiter les années bissextiles
if (indiceMois == 1) {
jourFin=28;
choix=gtk_combo_box_get_active(GTK_COMBO_BOX(c[2]));
if ((1900+choix)%4 == 0 && (1900+choix)%100 != 0) jourFin=29;
}
//
for(i = 0;i < jourFin;i++) {
gtk_list_store_append(l, &iter);
gtk_list_store_set(l, &iter, 0, i+1, -1);
}
gtk_combo_box_set_active(GTK_COMBO_BOX(c[0]), iactif);
return 0;
}

gboolean traitement (gpointer d) {

time_t maintenant;
time_t debut;
int dif;
int aMi,aH,aJ,aMo;
char nbS[64];
gchar* NomVaccation= NULL;
int choix;

// récupération du contenu des combobox
choix = gtk_combo_box_get_active(GTK_COMBO_BOX(c[0]));
naissance->tm_mday = choix+1;
//
choix = gtk_combo_box_get_active(GTK_COMBO_BOX(c[1]));
if (choixMoisPrecedent != choix) {
naissance->tm_mon = choix;
modificationComboJour(choix);
choixMoisPrecedent=choix;
}
//
choix = gtk_combo_box_get_active(GTK_COMBO_BOX(c[2]));
naissance->tm_year = choix;
if (choixMoisPrecedent == 1) modificationComboJour(1);

//
choix=gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(s[0]));
naissance->tm_hour = choix;
//
choix=gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(s[1]));
naissance->tm_min = choix;


// calculs fondamentaux
maintenant = time(NULL);
debut = mktime(naissance);
dif = difftime(maintenant,debut);

// on traite l'age en secondes
if (dif < 0) dif = ceil(dif);
sprintf(nbS, "%'.0i", dif);
gtk_label_set_text(GTK_LABEL(e[5]), nbS);
// en minutes
aMi = dif/60;
if (aMi < 0) aMi = ceil(aMi);
sprintf(nbS, "%'.0f", floor(aMi));
gtk_label_set_text(GTK_LABEL(e[6]), nbS);


/***********************************************************************************************
***********************************************************************************************/

// en heures
aH = (dif/(3600*24))%6;
if (aH < 0) aH = ceil(aH);
sprintf(nbS, "%'.0f", floor(aH));
gtk_label_set_text(GTK_LABEL(e[7]), nbS);
// en jours
aJ = dif/(3600*24);
if (aJ < 0) aJ = ceil(aJ);
sprintf(nbS, "%'.0f", floor(aJ));
gtk_label_set_text(GTK_LABEL(e[8]), nbS);
// en mois

aMo = (dif/(3600*24))%6;
switch (aMo)
{
case 0: {sprintf(NomVaccation,"Deuxieme nuit");
gtk_label_set_text(GTK_LABEL(e[9]),NomVaccation);}
case 1: {sprintf(NomVaccation,"Troisième nuit");
gtk_label_set_text(GTK_LABEL(e[9]),NomVaccation);}
case 2: {sprintf(NomVaccation,"Quatrieme nuit");
gtk_label_set_text(GTK_LABEL(e[9]),NomVaccation);}
case 3: {sprintf(NomVaccation,"Repos Légal");
gtk_label_set_text(GTK_LABEL(e[9]),NomVaccation);}
case 4: {sprintf(NomVaccation,"Repos Compensateur");
gtk_label_set_text(GTK_LABEL(e[9]),NomVaccation);}
case 5: {sprintf(NomVaccation,"Premiere Nuit");
gtk_label_set_text(GTK_LABEL(e[9]),NomVaccation);}
default: {sprintf(NomVaccation,"Erreur");
gtk_label_set_text(GTK_LABEL(e[9]),NomVaccation);}
}
// gtk_label_set_text(GTK_LABEL(e[9]),NomVaccation);
g_free(NomVaccation) ;

/*
gchar* sUtf8;
*/
/* Creation du label avec g_locale_to_utf8 */
/*
sUtf8 = g_locale_to_utf8("Texte à afficher", -1, NULL, NULL, NULL);
pLabel=gtk_label_new(sUtf8);
g_free(sUtf8);
*/




/* if (aMo < 0) aMo = ceil(aMo);
sprintf(nbS, "%'.0f", floor(aMo));
gtk_label_set_text(GTK_LABEL(e[9]), NomVaccation);
*/

/**********************************************************************************************
**********************************************************************************************/
gtk_widget_show_all(f);

while (g_main_context_iteration(NULL, FALSE));
//une solution de boucle avant de trouver la fonction gtk_timeout_add...
//usleep(100);
//traitement();

// doit retourner true pour être réexécuter
return TRUE;
}





Sebman

9 réponses

cptpingu Messages postés 3837 Date d'inscription dimanche 12 décembre 2004 Statut Modérateur Dernière intervention 28 mars 2023 123
9 déc. 2010 à 12:00
Ta fonction traitement est censé prendre un gpointer, or tu l'utilises et la déclare sans argument.
Je te conseille de mettre ton main tout en bas, en dessous des autres fonctions et ensuite retirer les déclarations de prototype qui ne sont pas obligatoire.

* Tu dois passer un gpointer à la fonction traitement donc: traitement(f) et non traitement().
* Tu fais un: sprintf(NomVaccation,"Deuxieme nuit"), mais NomVaccation est NULL ! Tu dois lui allouer de la mémoire.
* Ajoute les flags -W -Wall à ta ligne de compilation, tu auras plus de conseil (notamment tu verras les variables inutilisées...)

________________________________________________________________________
Historique de mes créations, et quelques articles:
[ http://0217021.free.fr/portfolio http://0217021.free.fr/portfolio]
Merci d'utiliser Réponse acceptée si un post répond à votre question
3
cptpingu Messages postés 3837 Date d'inscription dimanche 12 décembre 2004 Statut Modérateur Dernière intervention 28 mars 2023 123
9 déc. 2010 à 13:03
Ben retire le g_free(NomVaccation).
Sinon tu essaies de libérer une ressource que tu n'as pas alloué toi même. D'ou l'erreur.

________________________________________________________________________
Historique de mes créations, et quelques articles:
[ http://0217021.free.fr/portfolio http://0217021.free.fr/portfolio]
Merci d'utiliser Réponse acceptée si un post répond à votre question
3
cptpingu Messages postés 3837 Date d'inscription dimanche 12 décembre 2004 Statut Modérateur Dernière intervention 28 mars 2023 123
10 déc. 2010 à 10:14
Et avec "gchar NomVaccation[20]" ?

________________________________________________________________________
Historique de mes créations, et quelques articles:
[ http://0217021.free.fr/portfolio http://0217021.free.fr/portfolio]
Merci d'utiliser Réponse acceptée si un post répond à votre question
3
cs_sebman Messages postés 37 Date d'inscription mercredi 29 mai 2002 Statut Membre Dernière intervention 11 décembre 2010
9 déc. 2010 à 13:01
Tout dabord merci pour ta réponse bien rapide.
Je tiens à préciser que je suis très débutant en prog.

Alors j'ai rajouter un 'f' dans la fonction traitement
Et
gchar* NomVaccation[20];
Pour les variables inutilisés je verrai plus tard, merci pour tes conseils.


Voilà le résultat de la compilation qui échoue:


$ ./age3
*** glibc detected *** ./age3: munmap_chunk(): invalid pointer: 0xbfb667b0 ***
===== Backtrace: =========
/lib/tls/i686/cmov/libc.so.6(cfree+0x1bb)[0xb78416bb]
/usr/lib/libglib-2.0.so.0(g_free+0x31)[0xb7960b81]
./age3[0x804ac1c]
./age3[0x8049f71]
/lib/tls/i686/cmov/libc.so.6(__libc_start_main+0xe0)[0xb77e8450]
./age3[0x8049791]
===== Memory map: ========
08048000-0804b000 r-xp 00000000 08:06 10376 /media/Reserve90/Programmation/C-C++/Age/age-0.5/CoreDumped/age3
0804b000-0804c000 rw-p 00003000 08:06 10376 /media/Reserve90/Programmation/C-C++/Age/age-0.5/CoreDumped/age3
0804c000-0821e000 rw-p 0804c000 00:00 0 [heap]
b6ef9000-b6efa000 r-xp 00000000 08:02 358311 /usr/lib/gtk-2.0/2.10.0/immodules/im-cedilla.so
b6efa000-b6efb000 rw-p 00000000 08:02 358311 /usr/lib/gtk-2.0/2.10.0/immodules/im-cedilla.so
b6efb000-b6fff000 rw-p b6efb000 00:00 0
b6fff000-b7086000 r--p 00000000 08:02 301921 /usr/share/fonts/truetype/ttf-dejavu/DejaVuSans-Bold.ttf
b7086000-b7108000 rw-p b7086000 00:00 0
b7108000-b7159000 r--p 00000000 08:02 300339 /usr/share/fonts/truetype/ttf-dejavu/DejaVuSans-ExtraLight.ttf
b7159000-b71db000 rw-p b7159000 00:00 0
b71db000-b71dd000 r-xp 00000000 08:02 251909 /usr/lib/pango/1.6.0/modules/pango-basic-fc.so
b71dd000-b71de000 rw-p 00001000 08:02 251909 /usr/lib/pango/1.6.0/modules/pango-basic-fc.so
b71de000-b71e8000 r--p 00000000 08:02 311004 /usr/share/locale-langpack/fr/LC_MESSAGES/glib20.mo
b71e8000-b71f8000 r--p 00000000 08:02 301851 /usr/share/fonts/truetype/thai/Purisa.ttf
b71f8000-b71fe000 r--s 00000000 08:02 276589 /var/cache/fontconfig/945677eb7aeaf62f1d50efc3fb3ec7d8-x86.cache-2
b71fe000-b7201000 r--s 00000000 08:02 276082 /var/cache/fontconfig/e383d7ea5fbe662a33d9b44caf393297-x86.cache-2
b7201000-b7202000 r--s 00000000 08:02 276586 /var/cache/fontconfig/c69f04ab05004e31a6d5e715764f16d8-x86.cache-2
b7202000-b7205000 r--s 00000000 08:02 276592 /var/cache/fontconfig/a755afe4a08bf5b97852ceb7400b47bc-x86.cache-2
b7205000-b720c000 r--s 00000000 08:02 276084 /var/cache/fontconfig/6d41288fd70b0be22e8c3a91e032eec0-x86.cache-2
b720c000-b7214000 r--s 00000000 08:02 276080 /var/cache/fontconfig/e3de0de479f42330eadf588a55fb5bf4-x86.cache-2
b7214000-b721c000 r--s 00000000 08:02 276578 /var/cache/fontconfig/0f34bcd4b6ee430af32735b75db7f02b-x86.cache-2
b721c000-b723f000 r--p 00000000 08:02 311392 /usr/share/locale-langpack/fr/LC_MESSAGES/libc.mo
b723f000-b7267000 r-xp 00000000 08:02 211502 /usr/lib/gtk-2.0/2.10.0/engines/libclearlooks.so
b7267000-b7268000 rw-p 00028000 08:02 211502 /usr/lib/gtk-2.0/2.10.0/engines/libclearlooks.so
b7268000-b728d000 r--p 00000000 08:02 310904 /usr/share/locale-langpack/fr/LC_MESSAGES/gtk20-properties.mo
b728d000-b7296000 r-xp 00000000 08:02 332393 /lib/tls/i686/cmov/libnss_files-2.7.so
b7296000-b7298000 rw-p 00008000 08:02 332393 /lib/tls/i686/cmov/libnss_files-2.7.so
b7298000-b72a0000 r-xp 00000000 08:02 332395 /lib/tls/i686/cmov/libnss_nis-2.7.so
b72a0000-b72a2000 rw-p 00007000 08:02 332395 /lib/tls/i686/cmov/libnss_nis-2.7.so
b72a2000-b72b6000 r-xp 00000000 08:02 332387 /lib/tls/i686/cmov/libnsl-2.7.so
b72b6000-b72b8000 rw-p 00013000 08:02 332387 /lib/tls/i686/cmov/libnsl-2.7.so
b72b8000-b72ba000 rw-p b72b8000 00:00 0
b72ba000-b72c1000 r-xp 00000000 08:02 332389 /lib/tls/i686/cmov/libnss_compat-2.7.so
b72c1000-b72c3000 rw-p 00006000 08:02 332389 /lib/tls/i686/cmov/libnss_compat-2.7.so
b72c3000-b72c4000 r--s 00000000 08:02 276580 /var/cache/fontconfig/4c73fe0c47614734b17d736dbde7580a-x86.cache-2
b72c4000-b72c7000 r--s 00000000 08:02 276579 /var/cache/fontconfig/de156ccd2eddbdc19d37a45b8b2aac9c-x86.cache-2
b72c7000-b72c8000 r--s 00000000 08:02 276124 /var/cache/fontconfig/4794a0821666d79190d59a36cb4f44b5-x86.cache-2
b72c8000-b72cb000 r--s 00000000 08:02 276078 /var/cache/fontconfig/de9486f0b47a4d768a594cb4198cb1c6-x86.cache-2
b72cb000-b72d2000 r--s 00000000 08:02 276584 /var/cache/fontconfig/d52a8644073d54c13679302ca1180695-x86.cache-2
b72d2000-b72d8000 r--s 00000000 08:02 276079 /var/cache/fontconfig/089dead882dea3570ffc31a9898cfb69-x86.cache-2
b72d8000-b72e9000 r--p 00000000 08:02 311005 /usr/share/locale-langpack/fr/LC_MESSAGES/gtk20.mo
b72e9000-b7328000 r--p 00000000 08:02 219015 /usr/lib/locale/fr_FR.utf8/LC_CTYPE
b7328000-b7409000 r--p 00000000 08:02 219014 /usr/lib/locale/fr_FR.utf8/LC_COLLATE
b7409000-b740c000 rw-p b7409000 00:00 0
b740c000-b7420000 r-xp 00000000 08:02 332403 /lib/tls/i686/cmov/libpthread-2.7.so
b7420000-b7422000 rw-p 00013000 08:02 332403 /lib/tls/i686/cmov/libpthread-2.7.so
b7422000-b7424000 rw-p b7422000 00:00 0
b7424000-b7428000 r-xp 00000000 08:02 195643 /usr/lib/libXdmcp.so.6.0.0
b7428000-b7429000 rw-p 00003000 08:02 195643 /usr/lib/libXdmcp.so.6.0.0
b7429000-b742b000 r-xp 00000000 08:02 195632 /usr/lib/libXau.so.6.0.0
b742b000-b742c000 rw-p 00001000 08:02 195632 /usr/lib/libXau.so.6.0.0
b742c000-b744b000 r-xp 00000000 08:02 195794 /usr/lib/libexpat.so.1.5.2
b744b000-b744d000 rw-p 0001e000 08:02 195794 /usr/lib/libexpat.so.1.5.2
b744d000-b744e000 rw-p b744d000 00:00 0
b744e000-b7465000 r-xp 00000000 08:02 196473 /usr/lib/libxcb.so.1.0.0
b7465000-b7466000 rw-p 00016000 08:02 196473 /usr/lib/libxcb.so.1.0.0
b7466000-b7467000 r-xp 00000000 08:02 196471 /usr/lib/libxcb-xlib.so.0.0.0
b7467000-b7468000 rw-p 00000000 08:02 196471 /usr/lib/libxcb-xlib.so.0.0.0
b7468000-b748e000 r-xp 00000000 08:02 196141 /usr/lib/libpcre.so.3.12.1
b748e000-b748f000 rw-p 00026000 08:02 196141 /usr/lib/libpcre.so.3.12.1
b748f000-b7499000 r-xp 00000000 08:02 421013 /lib/libgcc_s.so.1
b7499000-b749a000 rw-p 0000a000 08:02 421013 /lib/libgcc_s.so.1
b749a000-b7582000 r-xp 00000000 08:02 194635 /usr/lib/libstdc++.so.6.0.9
b7582000-b7585000 r--p 000e8000 08:02 194635 /usr/lib/libstdc++.so.6.0.9
b7585000-b7587000 rw-p 000eb000 08:02 194635 /usr/lib/libstdc++.so.6.0.9
b7587000-b758e000 rw-p b7587000 00:00 0
b758e000-b75b6000 r-xp 00000000 08:02 196301 /usr/lib/libpixman-1.so.0.10.0
b75b6000-b75b7000 rw-p 00027000 08:02 196301 /usr/lib/libpixman-1.so.0.10.0
b75b7000-b75d9000 r-xp 00000000 08:02 194843 /usr/lib/libpng12.so.0.15.0
b75d9000-b75da000 rw-p 00022000 08:02 194843 /usr/lib/libpng12.so.0.15.0
b75da000-b75ee000 r-xp 00000000 08:02 196485 /usr/lib/libz.so.1.2.3.3
b75ee000-b75ef000 rw-p 00013000 08:02 196485 /usr/lib/libz.so.1.2.3.3
b75ef000-b7659000 r-xp 00000000 08:02 194390 /usr/lib/libfreetype.so.6.3.16
b7659000-b765c000 rw-p 0006a000 08:02 194390 /usr/lib/libfreetype.so.6.3.16
b765c000-b7682000 r-xp 00000000 08:02 197379 /usr/lib/libpangoft2-1.0.so.0.2002.3
b7682000-b7683000 rw-p 00026000 08:02 197379 /usr/lib/libpangoft2-1.0.so.0.2002.3
b7683000-b7684000 rw-p b7683000 00:00 0
b7684000-b768c000 r-xp 00000000 08:02 195639 /usr/lib/libXcursor.so.1.0.2
b768c000-b768d000 rw-p 00007000 08:02 195639 /usr/lib/libXcursor.so.1.0.2
b768d000-b7692000 r-xp 00000000 08:02 195667 /usr/lib/libXrandr.so.2.1.0
b7692000-b7693000 rw-p 00005000 08:02 195667 /usr/lib/libXrandr.so.2.1.0
b7693000-b769a000 r-xp 00000000 08:02 195655 /usr/lib/libXi.so.6.0.0
b769a000-b769b000 rw-p 00006000 08:02 195655 /usr/lib/libXi.so.6.0.0
b769b000-b769d000 r-xp 00000000 08:02 195657 /usr/lib/libXinerama.so.1.0.0
b769d000-b769e000 rw-p 00001000 08:02 195657 /usr/lib/libXinerama.so.1.0.0
b769e000-b76a5000 r-xp 00000000 08:02 195669 /usr/lib/libXrender.so.1.3.0
b76a5000-b76a6000 rw-p 00007000 08:02 195669 /usr/lib/libXrender.so.1.3.0
b76a6000-b76a7000 rw-p b76a6000 00:00 0
b76a7000-b76b4000 r-xp 00000000 08:02 195647 /usr/lib/libXext.so.6.4.0
b76b4000-b76b5000 rw-p 0000d000 08:02 195647 /usr/lib/libXext.so.6.4.0
b76b5000-b76de000 r-xp 00000000 08:02 195877 /usr/lib/libfontconfig.so.1.3.0
b76de000-b76df000 rw-p 00029000 08:02 195877 /usr/lib/libfontconfig.so.1.3.0
b76df000-b76e3000 r-xp 00000000 08:02 195649 /usr/lib/libXfixes.so.3.1.0
b76e3000-b76e4000 rw-p 00003000 08:02 195649 /usr/lib/libXfixes.so.3.1.0
b76e4000-b76e6000 r-xp 00000000 08:02 195641 /usr/lib/libXdamage.so.1.1.0
b76e6000-b76e7000 rw-p 00001000 08:02 195641 /usr/lib/libXdamage.so.1.1.0
b76e7000-b76e9000 r-xp 00000000 08:02 195637 /usr/lib/libXcomposite.so.1.0.0
b76e9000-b76ea000 rw-p 00001000 08:02 195637 /usr/Abandon


Ca me fait peur tout cela, vu que j'y comprend rien.
Merci de m'aider

Sebman
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
cs_sebman Messages postés 37 Date d'inscription mercredi 29 mai 2002 Statut Membre Dernière intervention 11 décembre 2010
10 déc. 2010 à 06:34
Alors la compilation à marché.
L'executable m'affiche bien une fenêtre, mais affiche "erreur" quelques soit le numéro de jour (variable ahH et aJ)

Au vu des erreurs de compilation, j'ai du faire une faute sur:
gtk_label_set_text




$ gcc `pkg-config --libs --cflags gtk+-2.0` age.c -o ageage.c: In function ‘traitement’:
age.c:333: warning: passing argument 1 of ‘sprintf’ from incompatible pointer type
/usr/include/stdio.h:341: note: expected ‘char * __restrict__’ but argument is of type ‘gchar **’
age.c:334: warning: passing argument 2 of ‘gtk_label_set_text’ from incompatible pointer type
/usr/include/gtk-2.0/gtk/gtklabel.h:112: note: expected ‘const gchar *’ but argument is of type ‘gchar **’
age.c:335: warning: passing argument 1 of ‘sprintf’ from incompatible pointer type
/usr/include/stdio.h:341: note: expected ‘char * __restrict__’ but argument is of type ‘gchar **’
age.c:336: warning: passing argument 2 of ‘gtk_label_set_text’ from incompatible pointer type
/usr/include/gtk-2.0/gtk/gtklabel.h:112: note: expected ‘const gchar *’ but argument is of type ‘gchar **’
age.c:337: warning: passing argument 1 of ‘sprintf’ from incompatible pointer type
/usr/include/stdio.h:341: note: expected ‘char * __restrict__’ but argument is of type ‘gchar **’
age.c:338: warning: passing argument 2 of ‘gtk_label_set_text’ from incompatible pointer type
/usr/include/gtk-2.0/gtk/gtklabel.h:112: note: expected ‘const gchar *’ but argument is of type ‘gchar **’
age.c:339: warning: passing argument 1 of ‘sprintf’ from incompatible pointer type
/usr/include/stdio.h:341: note: expected ‘char * __restrict__’ but argument is of type ‘gchar **’
age.c:340: warning: passing argument 2 of ‘gtk_label_set_text’ from incompatible pointer type
/usr/include/gtk-2.0/gtk/gtklabel.h:112: note: expected ‘const gchar *’ but argument is of type ‘gchar **’
age.c:341: warning: passing argument 1 of ‘sprintf’ from incompatible pointer type
/usr/include/stdio.h:341: note: expected ‘char * __restrict__’ but argument is of type ‘gchar **’
age.c:342: warning: passing argument 2 of ‘gtk_label_set_text’ from incompatible pointer type
/usr/include/gtk-2.0/gtk/gtklabel.h:112: note: expected ‘const gchar *’ but argument is of type ‘gchar **’
age.c:343: warning: passing argument 1 of ‘sprintf’ from incompatible pointer type
/usr/include/stdio.h:341: note: expected ‘char * __restrict__’ but argument is of type ‘gchar **’
age.c:344: warning: passing argument 2 of ‘gtk_label_set_text’ from incompatible pointer type
/usr/include/gtk-2.0/gtk/gtklabel.h:112: note: expected ‘const gchar *’ but argument is of type ‘gchar **’
age.c:345: warning: passing argument 1 of ‘sprintf’ from incompatible pointer type
/usr/include/stdio.h:341: note: expected ‘char * __restrict__’ but argument is of type ‘gchar **’
age.c:346: warning: passing argument 2 of ‘gtk_label_set_text’ from incompatible pointer type
/usr/include/gtk-2.0/gtk/gtklabel.h:112: note: expected ‘const gchar *’ but argument is of type ‘gchar **’



alors jai changé:

gchar* NomVaccation[20];
par
char NomVaccation[20];

Alors plus d'erreur lors de la compilation

La fenêtre s'ouvre, mais ma variable NomVaccation reste sur Erreur soit sur le "default:" du switch

Merci de ton aide

Bonne journée

Sebman
0
cs_sebman Messages postés 37 Date d'inscription mercredi 29 mai 2002 Statut Membre Dernière intervention 11 décembre 2010
10 déc. 2010 à 13:13
Même résultat:

Compilation ok
La fenêtre s'ouvre, mais ma variable NomVaccation reste sur Erreur soit sur le "default:" du switch

Je me penche sur mes lignes de 333 à 346 sur

gtk_label_set_text(GTK_LABEL(e[9]),NomVaccation);}




Sebman
0
cptpingu Messages postés 3837 Date d'inscription dimanche 12 décembre 2004 Statut Modérateur Dernière intervention 28 mars 2023 123
10 déc. 2010 à 14:29
Il te manque les "break" dans ton switch, tout simplement :p

________________________________________________________________________
Historique de mes créations, et quelques articles:
[ http://0217021.free.fr/portfolio http://0217021.free.fr/portfolio]
Merci d'utiliser Réponse acceptée si un post répond à votre question
0
cs_sebman Messages postés 37 Date d'inscription mercredi 29 mai 2002 Statut Membre Dernière intervention 11 décembre 2010
11 déc. 2010 à 05:27
Ah ouaips

La cela marche beaucoup mieux

J'ai encore quelques erreurs (valeurs absolue des variable) mais j'ai vachement progrèssé.

Remerciement tout plein.
Avec un poil d'avance je te souhaite de joyeuses fêtes et mes meilleurs voeux pour 2011.

Sebman
0
cptpingu Messages postés 3837 Date d'inscription dimanche 12 décembre 2004 Statut Modérateur Dernière intervention 28 mars 2023 123
11 déc. 2010 à 13:01
De même ! Bonne continuation :)
________________________________________________________________________
Historique de mes créations, et quelques articles:
[ http://0217021.free.fr/portfolio http://0217021.free.fr/portfolio]
Merci d'utiliser Réponse acceptée si un post répond à votre question
0
Rejoignez-nous