structure et fichier header
Bonjour,
Deja je m'excuse d'ance pour l orto ;) .
Sinon voila , j e voudrais envoyer une structure a une fonction qui se trouve dans le fichier affich.c et le fichier qui contien le prototype de la fonction & la structure sont dans affich.h
Voici les code (je mais le code minimal :^ )
te.c (programme principale)
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| #include "../include/affich.h"
typedef struct _struct_test_t {
int e;
} test_t;
int main(int argc, char *argv[])
{
s_t *pe = malloc(sizeof(s_t));
test_t *tt = malloc(sizeof(test_t));
pe->bheu = 10;
affich("test", pe, tt);
return 0;
} |
affic.c ( fonction )
Code:
1 2 3 4 5 6 7 8 9 10
|
#include "../include/affich.h"
void affich(const char *str, s_t *pe, test_t *tt)
{
printf("%s\n",str);
printf("struct pe: %d\n", pe->bheu);
/*tt->e = 20;
pritf("struct tt : %d\n", tt->e);*/
} |
affich.h (prototype & struct)
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
|
#ifndef __AFFICH__
#define __AFFICH__
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
typedef struct _s_s {
int bheu;
} s_t;
void affich(const char *str, s_t *pe, test_t *tt);
#endif /*__AFFICH__*/ |
a la compilation j'obtien les erreus suivantes :
Code:
1 2 3 4 5 6 7 8 9 10 11 12
|
$ make install
/usr/bin/gcc -o te src/te.c src/affich.c include/affich.h
In file included from src/te.c:1:
src/../include/affich.h:13: error: expected declaration specifiers or ... before test_t
src/te.c: In function main:
src/te.c:15: error: too many arguments to function affich
In file included from src/affich.c:1:
src/../include/affich.h:13: error: expected declaration specifiers or ... before test_t
src/affich.c:4: error: expected declaration specifiers or ... before test_t
include/affich.h:13: error: expected declaration specifiers or ... before test_t
make: *** [te] Erreur 1 |
Je constate bien que ma fonction n'aprécie pas du tous ma structure test_t ... si vous pourriez men dire plus car je pensais qu'il sufisé d'envoie la struct normalement .... .
Merci
++