Problème avec path_max

Bonjour,

j’ai un problème avec la constante PATH_MAX lors de la compilation.

Je l’ai utilisé dans un programme test :

#include<stdio.h>
#include<stdlib.h>
#include<unistd.h>
#include<limits.h>                     
 
char *Rep_Courant(void){               
char *Chemin;
 
char *Tab = (char *) malloc(sizeof(PATH_MAX));
Chemin = getcwd(Tab, PATH_MAX);
printf("%s", Chemin);
return Chemin;
}
 
 
int main(void){
 
Rep_Courant();
return 0;
}

Là tout va bien, il me renvoi le répertoire. Mais quand je l’utilise dans un autre programme un peu plus compliqué (en utilisant la même fonction “Rep_Courant”), j’ai un joli :

bastos@bastos-System-Product-Name:~/Bureau/Projet/Test$ make
gcc -Wall -ansi -pedantic -g   -c -o Repertoire.o Repertoire.c
Repertoire.c: In function ?Rep_Courant?:
Repertoire.c:13:36: erreur: ?PATH_MAX? undeclared (first use in this function)
Repertoire.c:13:36: note: each undeclared identifier is reported only once for each function it appears in
make: *** [Repertoire.o] Erreur 1

Je ne comprend pas du tout d’où vient le problème. Les bibliothèques “unistd.h” et “limits.h” étant bien sûr utilisées…

Hop : stackoverflow.com…

Merci Duckduckgo :slight_smile:

Et sinon, tu peux tenter un gcc -E gcc -Wall -ansi -pedantic -g Repertoire.c pour voir le code après #include.

Merci beaucoup de ton aide :). Il me manquais juste le “linux/” devant “limits.h” en fait.
Edité le 19/03/2013 à 08:36