Erreur avec sizeof et compilation séparée
Bonjour,
Je n'arrive pas à comprendre l'erreur suivante à la compilation :
Citation:
gcc main.c longueur.o -o prog
main.c: Dans la fonction «main» :
main.c:19: erreur: invalid application of «sizeof» to incomplete type «const unsigned char[]»
make: *** [prog] Erreur 1
main.c :
Code:
1 2 3 4 5 6 7 8 9 10 11 12
| #include <stdio.h>
extern const int x;
extern const unsigned char tab[];
int main(void)
{
printf ("taille x = %d \n", sizeof x);
printf ("taille tab = %d \n", sizeof tab);
return 0;
} |
longueur.c
Code:
1 2 3 4 5
| #include <stdio.h>
const int x = 8;
const unsigned char tab[] = {'c', 'h', 'a', 'r'}; |
Visiblement le "sizeof tab" pose problème mais c'est ok pour le "sizeof x"