IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Visual C++ Discussion :

mais j'ai quand même une question


Sujet :

Visual C++

  1. #1
    Débutant
    Profil pro
    Développeur informatique
    Inscrit en
    Décembre 2008
    Messages
    1 022
    Détails du profil
    Informations personnelles :
    Localisation : France, Mayenne (Pays de la Loire)

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Décembre 2008
    Messages : 1 022
    Points : 332
    Points
    332
    Par défaut mais j'ai quand même une question
    bonjour,
    J'ai un code qui me compile pas et le message est abscons :
    Je vous met le code et le message
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    	erc CVirtualEquations::ProcessVirtualEquations( CAnalysedSegmentM^ pSegment)
    	{ // 0
    		erc ErrorCode = 0;
    		int nPos;
    		int nEqParParagraph = 0;
    		int nOldParagraph;
    		CElementSemantiqueM^ pProposition;
    		CAnalysedChunkM^ pChunk;
    		CVirtualEquations^ pEquation;
    		CAnalysedWordM^ pPreviousWord;
    		CAnalysedWordM^ pNextWord;
    		CAnalysedWordM^ pNext2Word;
    		System::String^ wsProposition;
    		System::String^ wsWord;
    		System::String^ wsNext2Word;
    		System::String^ wsLemma;
    		System::String^ wsSubject;
    		System::String^ wsOperator;
    		System::String^ wsOperande;
    		List<CElementSemantiqueM^>::Enumerator itProposition;
    		List<CAnalysedWordM^>::Enumerator itWord;
    		List<CAnalysedWordM^>::Enumerator itBack;
    		const wchar_t* chars;
    		enPOSM^ POS;
    		bool bNewEquation = false;
    		bool bOperator = false;
    		bool bSubject = false;
    		size_t iSize;
    		try
    		{ // 1
    			itWord = pSegment->pLinguisticSegment->pListWord->GetEnumerator();
    			itWord.MoveNext();
    			itBack = itWord;
    			for each(  CChunker::pWord in pSegment->pLinguisticSegment->pListWord) //ligne 284
    			{ // 2
    				if( itWord.MoveNext())
    				{ // 3
    					pNextWord = itWord.Current;
    					if( itWord.MoveNext())
    					{ // 4
    						pNext2Word = itWord.Current;
    					} // 4
    				} // 3
    				itWord = itBack;
    				itWord.MoveNext();
    				wsWord = CChunker::pWord->wsWord;
    				POS = CChunker::pWord->POS;
    				wsLemma = CChunker::pWord->wsLemma;
    				switch( CChunker::pWord->POS)
    				{ // 3
    					case enPOSM::POS_NOUN:
    						if( wsOperator->Length == 0)
    						{ // 4
    							wsWord = CChunker::pWord->wsWord;
    							wsSubject += CChunker::pWord->wsWord;
    							wsSubject += L" ";
    						} // 4
    						else
    						{ // 4
    							if( bOperator == false)
    							{ // 5
    								wsOperande += CChunker::pWord->wsWord;
    								wsOperande += L" ";
    							} // 5
    							else
    								bOperator = false;
    						} // 4
    						break;
    					case enPOSM::POS_ADJ:
    						if( wsSubject->Length == 0)
    						{ // 4
    							wsSubject += CChunker::pWord->wsWord;
    							wsSubject += L" ";
    							bSubject = true;
    						} // 4
    						if( bSubject == false && bOperator == false)
    						{ // 4
    							wsOperande += CChunker::pWord->wsWord;
    							wsOperande += L" ";
    							bOperator = false;
    						} // 4
    						else
    						{ // 4
    							bOperator = false;
    							bSubject = false;
    						} // 4
    						break;
    					case enPOSM::POS_VERB:
    						wsNext2Word = pNext2Word->wsWord;
    						wsWord = CChunker::pWord->wsWord;
    						if( wsWord == L"increases")
    						{ // 4
    							bOperator = true;
    							wsOperator = L"++";
    						} // 4
    						else if( wsWord == L"decreases")
    						{ // 4
    							bOperator = true;
    							wsOperator = L"--";
    						} // 4
    						else if( wsWord == L"is" && pNextWord->wsWord == L"greater")
    						{ // 4
    							bOperator = true;
    							wsOperator = L">";
    						} // 4
    						else if(  wsWord == L"is" && pNextWord->wsWord == L"over")
    						{ // 4
    							bOperator = true;
    							wsOperator = L">";
    						} // 4
    						else if(  wsWord == L"is" && pNextWord->wsWord == L"lower")
    						{ // 4
    							bOperator = true;
    							wsOperator = L"<";
    						} // 4
    						else if( wsWord == L"is" && pNextWord->POS == enPOSM::POS_COLOR)
    						{ // 4
    							bOperator = true;
    							wsOperator = L"=";
    						} // 4
    						else if( wsWord == L"has")
    						{ // 4
    							bOperator = true;
    							wsOperator = L"==";
    						} // 4
    						else if(  wsWord == L"keeps" && pNext2Word->wsWord == L"same")
    						{ // 4
    							bOperator = true;
    							wsOperator = L"==";
    						} // 4
    						break;
    					case enPOSM::POS_NB:
    						nPos =  CChunker::pWord->wsWord->IndexOf( L"-", nPos);
    						if( nPos > 0 && nPos < 3)
    						{ // 4
    							//erreur lexicale
    							if( pSegment->pLinguisticSegment->pListProposition->Count > 0)
    							{ // 5
    								itProposition = pSegment->pLinguisticSegment->pListProposition->GetEnumerator();
    								if( itProposition.MoveNext())
    								{ // 6
    									pProposition = itProposition.Current;
    									nParagraph = pProposition->idParagraph;
    									for each( pChunk in pProposition->pListChunk)
    									{ // 7
    										for each(  CChunker::pWord in pChunk->pListWord)
    										{ // 8
    											wsProposition += CChunker::pWord->wsWord;
    											wsProposition += L"";
    										} // 8
    									} // 7
    								} // 6
    								chars = (const wchar_t*)(Marshal::StringToHGlobalUni( wsProposition)).ToPointer();
    								string sProposition = CStrConv::awcstombs( (wchar_t*)chars);
    								Marshal::FreeHGlobal(IntPtr((void*)chars));
    								string msg = "error: there is a non acceptable charachter in this sentence : " + sProposition;
    								CStrConv::StrFreeA( (char*)sProposition.c_str());
    								throw Doc_exception ( msg.c_str(), nParagraph);
    							} // 5
    						} // 4
    						else if( pNextWord->POS != enPOSM::POS_MARK && pNextWord->wsWord != L"-")
    						{ // 4
    							wsOperande = pNextWord->wsWord;
    						} //4
    						break;
    					case enPOSM::POS_COLOR:
    						if( pNextWord->POS != enPOSM::POS_MARK && pNextWord->wsWord != L"-")
    						{ // 4
    							wsWord = CChunker::pWord->wsWord;
    							wsOperande = pNextWord->wsWord;
    						} // 4
    						break;
    					case enPOSM::POS_COMMA:
    					case enPOSM::POS_CONJ:
    					case enPOSM::POS_PIVOT:
    						bNewEquation = true;
    						break;
    					case enPOSM::POS_STOPMARK:
    					case enPOSM::POS_MARK:
    						if( wsSubject->Length != 0 && wsOperator->Length != 0 && wsOperande->Length != 0)
    						{ // 4
    							bNewEquation = true;
    							if( nParagraph >= nOldParagraph)
    							{ // 5
    								nEqParParagraph++;
    								nOldParagraph = nParagraph;
    							} // 5
    						} // 4
    						break;
    					default:
    						break;
    				} // 3
    				int len;
    				if( bNewEquation == true)
    				{ // 3
    					if( wsOperator->Length > 0)
    					{ // 4
    						pEquation = gcnew CVirtualEquations;
    						pEquation->wsSubject = wsSubject;
    						pEquation->wsOperator = wsOperator;
    						pEquation->wsOperande = wsOperande;
    						pEquation->idParagraph = nParagraph;
    						pEquation->nEqParParagraph = nEqParParagraph;
    						pSegment->pLinguisticSegment->pListEquations.Add( pEquation);
    						iSize = pSegment->pLinguisticSegment->pListEquations.Count;
    						len = iSize;
    						wsSubject = L"";
    						wsOperator = L"";
    						wsOperande = L"";
    					} // 4
    					bNewEquation = false;
    				} // 3
    				pPreviousWord = CChunker::pWord;
    			} // 2
    		} // 1
    		catch( Doc_exception &e )
    		{ // 1
    	        size_t len;
     
    			string msg = e.Doc_exception::what();
    			msg = msg + "\n";
    			// il reste à gèrer la mise en fichier et la libération des ressources (à voir)
    			// errno_t fopen_s( FILE** pFile, const char *filename, const char *mode)
    			fopen_s( &fp, sLogFile.c_str(), "a");
    			len = fprintf(  fp, msg.c_str());
    			fclose( fp);
    		} // 1
    		return( ErrorCode);
    	} // 0
    le message est :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1>..\..\..\..\Linguistic\Analyser\src\VirtualEquation.cpp(284): fatal error C1506: impossible de récupérer l'erreur relative à la portée du bloc
    celui qui m'aidera sera

  2. #2
    Membre chevronné

    Homme Profil pro
    Développeur informatique
    Inscrit en
    Avril 2013
    Messages
    610
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : Finance

    Informations forums :
    Inscription : Avril 2013
    Messages : 610
    Points : 1 878
    Points
    1 878
    Billets dans le blog
    21
    Par défaut
    et la ligne 284 après copier/coller devient laquelle?

  3. #3
    Expert éminent sénior
    Avatar de Médinoc
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Septembre 2005
    Messages
    27 369
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 40
    Localisation : France

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Septembre 2005
    Messages : 27 369
    Points : 41 518
    Points
    41 518
    Par défaut
    @stendhal666: Apparamment, la ligne 34.

    @JeanNoel53: Est-ce là la seule erreur du compilateur?
    Cela pourrait être un signe, tu sais. Par exemple, le signe que tu devrais décomposer ton code un peu plus, séparer cette méthode en plusieurs...

    Autres remarques:
    1. enPOSM semble être une enum class. Pourquoi boxes-tu ta variable POS? Tu n'as pas l'air d'en avoir vraiment besoin...
    2. Code passable : Sélectionner tout - Visualiser dans une fenêtre à part
      1
      2
      3
      chars = (const wchar_t*)(Marshal::StringToHGlobalUni( wsProposition)).ToPointer();
      string sProposition = CStrConv::awcstombs( (wchar_t*)chars);
      Marshal::FreeHGlobal(IntPtr((void*)chars));
      Pourquoi n'utilises-tu pas marshal_as? Ou au moins, StringToHGlobalAnsi() plutôt que séparer l'allocation d'un pointeur non-managé de la conversion?
    3. Code horrible : Sélectionner tout - Visualiser dans une fenêtre à part
      1
      2
      3
      string msg = "error: there is a non acceptable charachter in this sentence : " + sProposition;
      CStrConv::StrFreeA( (char*)sProposition.c_str());
      throw Doc_exception ( msg.c_str(), nParagraph);
      OH MY GOD WHAT THE FUCK
      Non-seulement tu fais un "free" sur la chaîne contenu dans une std::string sous ses pieds, mais tu l'utilises juste après?
    SVP, pas de questions techniques par MP. Surtout si je ne vous ai jamais parlé avant.

    "Aw, come on, who would be so stupid as to insert a cast to make an error go away without actually fixing the error?"
    Apparently everyone.
    -- Raymond Chen.
    Traduction obligatoire: "Oh, voyons, qui serait assez stupide pour mettre un cast pour faire disparaitre un message d'erreur sans vraiment corriger l'erreur?" - Apparemment, tout le monde. -- Raymond Chen.

  4. #4
    Débutant
    Profil pro
    Développeur informatique
    Inscrit en
    Décembre 2008
    Messages
    1 022
    Détails du profil
    Informations personnelles :
    Localisation : France, Mayenne (Pays de la Loire)

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Décembre 2008
    Messages : 1 022
    Points : 332
    Points
    332
    Par défaut Le code a été décomposé et j'en arrive à ...
    Le code a été décomposé et j'en arrive à une fonction simple qui provoque la même erreur qui est la seule erreur.
    Quant à la question de marchal J'ai trouvé cet exemple sur le forum MSDN
    Je donne le code et le diagnostique
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    	System::String^ CVirtualEquations::EditChunk( CAnalysedChunkM^ pChunk)
    	{
    		System::String^ wsProposition;
    		for each( CChunker::pWord in pChunk->pListWord)
    		{ // 1
    			wsProposition += CChunker::pWord->wsWord;
    			wsProposition += L"";
    		} // 1
    		return( wsProposition);
    	}
    et l'erreur toujours la même:
    alors j'ai modifié la méthode qui est devenu:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    	System::String^ CVirtualEquations::EditChunk( CAnalysedChunkM^ pChunk, CAnalysedWordM^ pWord)
    	{
    		System::String^ wsProposition;
    		for each( pWord in pChunk->pListWord)
    		{ // 1
    			wsProposition += pWord->wsWord;
    			wsProposition += L"";
    		} // 1
    		return( wsProposition);
    	}
     
    	System::String^ CVirtualEquations::EditProposition( CAnalysedChunkM^ pChunk, CElementSemantiqueM^ pProposition)
    	{ // 0
    		System::String^ wsProposition;
     
    		for each( pChunk in pProposition->pListChunk)
    		{ // 1
     
    		} // 1
    		return( wsProposition);
    	};
    et ça marche

  5. #5
    Expert éminent sénior
    Avatar de Médinoc
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Septembre 2005
    Messages
    27 369
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 40
    Localisation : France

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Septembre 2005
    Messages : 27 369
    Points : 41 518
    Points
    41 518
    Par défaut
    Ah oui, il n'aimait probablement pas ton utilisation bizarre du :: dans le for each.
    SVP, pas de questions techniques par MP. Surtout si je ne vous ai jamais parlé avant.

    "Aw, come on, who would be so stupid as to insert a cast to make an error go away without actually fixing the error?"
    Apparently everyone.
    -- Raymond Chen.
    Traduction obligatoire: "Oh, voyons, qui serait assez stupide pour mettre un cast pour faire disparaitre un message d'erreur sans vraiment corriger l'erreur?" - Apparemment, tout le monde. -- Raymond Chen.

  6. #6
    Débutant
    Profil pro
    Développeur informatique
    Inscrit en
    Décembre 2008
    Messages
    1 022
    Détails du profil
    Informations personnelles :
    Localisation : France, Mayenne (Pays de la Loire)

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Décembre 2008
    Messages : 1 022
    Points : 332
    Points
    332
    Par défaut oui
    je crois que tu a raison
    mais surtout il n'aime pas les CChunker::pWord

  7. #7
    Expert éminent sénior
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Février 2005
    Messages
    5 069
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 52
    Localisation : France, Val de Marne (Île de France)

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : Conseil

    Informations forums :
    Inscription : Février 2005
    Messages : 5 069
    Points : 12 113
    Points
    12 113
    Par défaut
    mais surtout il n'aime pas les CChunker::pWord
    Il n'aime pas cela parce que cela n'a AUCUN SENS.
    "CChunker::pWord" c'est un champ static et dans une boucle for c'est la déclaration d'une variable de boucle.

    Si vous cherchez bien, vous arriverez à compiler des choses qui n'ont aucun sens. Le compilateur n'est pas un validateur de logique.

    Lisez un vrai livre sur le C++, SVP.

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Cas d'école, mais casse tête quand même.
    Par lyvunny dans le forum Débuter avec Java
    Réponses: 5
    Dernier message: 08/08/2010, 12h25
  2. [MySQL] Tout en UTF8 mais problème accentuations quand même
    Par speedev dans le forum PHP & Base de données
    Réponses: 10
    Dernier message: 11/04/2007, 22h43
  3. Acheter un vieux PC, mais pas trop quand même
    Par Maxoo dans le forum Ordinateurs
    Réponses: 30
    Dernier message: 22/03/2007, 09h49
  4. Réponses: 5
    Dernier message: 01/03/2006, 11h09
  5. boucle simple dans une dataGrid avec quand même une erreur !
    Par fkr dans le forum VB 6 et antérieur
    Réponses: 2
    Dernier message: 07/11/2005, 15h04

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo