Meilleur auteur de réponses
une classe qui ne compile pas

Question
-
la classe CMorph ne compile pas avec des messages que je ne comprend pas:
#ifndef CMorph_H #define CMorph_H namespace SpecificationLoader { using namespace System; using namespace System::ComponentModel; using namespace System::Collections; using namespace System::Windows::Forms; using namespace System::Data; using namespace System::Drawing; using namespace System::IO; ref class CMorph { public: CMorph::CMorph(); CMorph::~CMorph(); static int CMorph::morphinit(void); /* Close exception list files and reopen */ static int CMorph::re_morphinit(); /* Try to find baseform (lemma) of word or collocation in POS. */ static char *CMorph::morphstr(char *, int); /* Try to find baseform (lemma) of individual word in POS. */ static char *CMorph::morphword(char *, int); static int CMorph::do_init(void); static char* CMorph::strtolower( char *str); private: static char* CMorph::WsCanonWord( int offset, int count, int pos, char* word, char* end); static int CMorph::strend(char *str1, char *str2); static char* CMorph::WordBase(char *word, int ender); static int CMorph::hasprep(char *s, int wdcnt); static char *CMorph::exc_lookup(char *word, int pos); static char *CMorph::morphprep(char *s); }; }; #endif
je vous met le fichier de code dans son début:
/* morph.c - WordNet search code morphology functions */ #include "StdAfx.h" #include "wn.h" #include "AlignStructure.h" #include "EnumerationM.hpp" #include "StructureM.h" #include "TypeDefsM.hpp" #include "POSM.h" #include "Layout.h" #include "ClasseAlignerManaged.hpp" #include "StrConv.h" #include "Morph.h" #define EXCFILE "%s/%s.exc" //------------------------------------------------------------------------------ static char *Id = "$Id: morph.cpp 1.6 2009/12/08 15:28:15Z Jean_Noel_Martin Exp Jean_Noel_Martin $"; namespace SpecificationLoader // Ligne 4 { using namespace System; // Ligne 6 using namespace System::ComponentModel; using namespace System::Collections; using namespace System::Windows::Forms; using namespace System::Data; using namespace System::Drawing; using namespace System::IO; char *sufx[] ={ /* Noun suffixes */ "s", "ses", "xes", "zes", "ches", "shes", "men", "ies", /* Verb suffixes */ "s", "ies", "es", "es", "ed", "ed", "ing", "ing", /* Adjective suffixes */ "er", "est", "er", "est" }; static char *addr[] ={ /* Noun endings */ "", "s", "x", "z", "ch", "sh", "man", "y", /* Verb endings */ "", "y", "e", "", "e", "", "e", "", /* Adjective endings */ "", "", "e", "e" }; static int offsets[NUMPARTS] = { 0, 0, 8, 16 }; static int cnts[NUMPARTS] = { 0, 8, 8, 4 }; static char msgbuf[256]; #define NUMPREPS 15 static struct { char *str; int strlen; } prepositions[NUMPREPS] = { "to", 2, "at", 2, "of", 2, "on", 2, "off", 3, "in", 2, "out", 3, "up", 2, "down", 4, "from", 4, "with", 4, "into", 4, "for", 3, "about", 5, "between", 7, }; namespace SpecificationLoader { using namespace System; using namespace System::ComponentModel; using namespace System::Collections; using namespace System::Windows::Forms; using namespace System::Data; using namespace System::Drawing; using namespace System::IO; CMorph::CMorph() { } CMorph::~CMorph() { } char* CMorph::strtolower( char *str) { register char *s = str; while(*s != '\0') { if(*s >= 'A' && *s <= 'Z') *s += 32; else if(*s == '(') { *s='\0'; break; } s++; } return(str); } /* Open exception list files */ int CMorph::morphinit(void) { static int done = 0; static int openerr = 0; if (!done) { if(OpenDB) { /* make sure WN database files are open */ openerr = do_init(); if (!openerr) done = 1; else openerr = -1; } else openerr = -1; } return(openerr); }
et e fichier d'erreur:
.\..\..\..\..\..\WordNet\src\lib\morph.cpp(90): error C2888: 'SpecificationLoader::CMorph::CMorph(void)' : impossible de définir un symbole dans un espace de noms 'SpecificationLoader' 1>..\..\..\..\..\..\WordNet\src\lib\morph.cpp(94): error C2888: 'SpecificationLoader::CMorph::~CMorph(void)' : impossible de définir un symbole dans un espace de noms 'SpecificationLoader' 1>..\..\..\..\..\..\WordNet\src\lib\morph.cpp(98): error C2888: 'char *SpecificationLoader::CMorph::strtolower(char *)' : impossible de définir un symbole dans un espace de noms 'SpecificationLoader' 1>..\..\..\..\..\..\WordNet\src\lib\morph.cpp(115): error C2888: 'int SpecificationLoader::CMorph::morphinit(void)' : impossible de définir un symbole dans un espace de noms 'SpecificationLoader' 1>..\..\..\..\..\..\WordNet\src\lib\morph.cpp(136): error C2888: 'int SpecificationLoader::CMorph::re_morphinit(void)' : impossible de définir un symbole dans un espace de noms 'SpecificationLoader'
qu'est ce qui fait générer ces erreurs
Jean Noël Martin
Réponses
-
https://msdn.microsoft.com/en-us/library/27zksbks.aspx?f=255&MSPPError=-2147217396
Vous avez défini un namespace SpecificationLoader dans un namespace SpecificationLoader.
Il vous manque systématiquement l'accolade fermante des namespaces dans votre .cpp.
Paul Bacelar, Ex - MVP VC++
- Marqué comme réponse JeanNoel53 samedi 3 octobre 2015 10:17