erreur: ‘strdup’ n’a pas été déclaré dans cette scope

J’essaie de construire et d’installer le compilateur et les bibliothèques Apache Thrift

Comme indiqué dans les instructions, exécutez ./configure && make

Et je reçois cette erreur:

 thrift 0.9.3 Building C++ Library ......... : no Building C (GLib) Library .... : no Building Java Library ........ : no Building C# Library .......... : no Building Python Library ...... : no Building Ruby Library ........ : no Building Haxe Library ........ : no Building Haskell Library ..... : no Building Perl Library ........ : no Building PHP Library ......... : no Building Erlang Library ...... : no Building Go Library .......... : no Building D Library ........... : no Building NodeJS Library ...... : no Building Lua Library ......... : no If something is missing that you think should be present, please skim the output of configure to find the missing component. Details are present in config.log. make all-recursive make[1]: Entering directory '/c/University/InternetOfThings/thrift-0.9.3' Making all in comstackr/cpp make[2]: Entering directory '/c/University/InternetOfThings/thrift-0.9.3/comstackr/cpp' /bin/sh ../../ylwrap src/thrifty.yy y.tab.c src/thrifty.cc y.tab.h `echo src/thrifty.cc | sed -es/cc$/hh/ -es/cpp$/hpp/ -es/cxx$/hxx/ -es/c++$/h++/ -es/c$/h/` y.output src/thrifty.output -- bison -y -d updating src/thrifty.hh make all-am make[3]: Entering directory '/c/University/InternetOfThings/thrift-0.9.3/comstackr/cpp' g++ -DHAVE_CONFIG_H -I. -I../.. -I../../lib/cpp/src/thrift -I./src -Wall -Wno-sign-compare -Wno-unused -g -O2 -std=c++11 -MT src/libparse_a-thrifty.o -MD -MP -MF src/.deps/libparse_a-thrifty.Tpo -c -o src/libparse_a-thrifty.o `test -f 'src/thrifty.cc' || echo './'`src/thrifty.cc src/thrifty.yy: In function 'int yyparse()': src/thrifty.yy:1311:30: error: 'strdup' was not declared in this scope Makefile:912: recipe for target 'src/libparse_a-thrifty.o' failed make[3]: *** [src/libparse_a-thrifty.o] Error 1 make[3]: Leaving directory '/c/University/InternetOfThings/thrift-0.9.3/comstackr/cpp' Makefile:588: recipe for target 'all' failed make[2]: *** [all] Error 2 make[2]: Leaving directory '/c/University/InternetOfThings/thrift-0.9.3/comstackr/cpp' Makefile:609: recipe for target 'all-recursive' failed make[1]: *** [all-recursive] Error 1 make[1]: Leaving directory '/c/University/InternetOfThings/thrift-0.9.3' Makefile:530: recipe for target 'all' failed make: *** [all] Error 2 

J’ai édité thrifty.yy et ajouté #include mais j’obtiens toujours la même erreur que strdup est manquant.

src/thrifty.yy:1311:30: error: 'strdup' was not declared in this scope (même erreur qu’auparavant avec ssortingng.h)

Qu’est-ce que j’oublie ici ?

Merci d’avance!

strdup n’est pas une fonction C standard. Lorsqu’un compilateur est configuré pour être ssortingctement conforme au langage C, il n’est pas autorisé à sauvegarder ses propres fonctions non standard personnalisées dans des en-têtes de bibliothèque standard tels que .

Vous pouvez résoudre ce problème en modifiant le compilateur pour comstackr du code C non standard (par exemple, dans gcc, comstackz avec -std=gnu11 au lieu de -std=c11 ). Ou alternativement, s’en tenir à la norme pure C.


… ou simplement mettre en œuvre strdup vous-même, c’est facile:

 #include  #include  char* strdup (const char* s) { size_t slen = strlen(s); char* result = malloc(slen + 1); if(result == NULL) { return NULL; } memcpy(result, s, slen+1); return result; }