Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
1187 connectés 

  FORUM HardWare.fr
  Programmation
  C++

  warning: suggest parentheses around assignment used as truth value

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

warning: suggest parentheses around assignment used as truth value

n°184183
monokrome
nocturne
Posté le 27-07-2002 à 11:44:35  profilanswer
 

Code :
  1. while (fgets(buffer, 256, statefile) != NULL) {
  2.  if ( right = strstr(buffer, "prog" )) {
  3. ...
  4. }

 
 
voila, dans un prog j'ai la ligne la (celle avec le if) qui me génere un warning, mais je comprends pas pourquoi..une recherche google & forum ne m'a pas apporté de solution.
 
 
 

Code :
  1. gcc -g -Wall -o seti seti.c
  2. ...
  3. seti.c: In function `read_workunit_infos':
  4. seti.c:48: warning: suggest parentheses around assignment used as truth value

 
 
voila, gcc 2.95.3 mais ca a pas d'importance je pense.
 
je débute en c et j'aimerais faire un truc propre, sans warnings
 
merci.

mood
Publicité
Posté le 27-07-2002 à 11:44:35  profilanswer
 

n°184188
LetoII
Le dormeur doit se réveiller
Posté le 27-07-2002 à 11:51:41  profilanswer
 

monokrome a écrit a écrit :

 

Code :
  1. while (fgets(buffer, 256, statefile) != NULL) {
  2.  if ( right = strstr(buffer, "prog" )) {
  3. ...
  4. }

 
 
voila, dans un prog j'ai la ligne la (celle avec le if) qui me génere un warning, mais je comprends pas pourquoi..une recherche google & forum ne m'a pas apporté de solution.
 
 
 

Code :
  1. gcc -g -Wall -o seti seti.c
  2. ...
  3. seti.c: In function `read_workunit_infos':
  4. seti.c:48: warning: suggest parentheses around assignment used as truth value

 
 
voila, gcc 2.95.3 mais ca a pas d'importance je pense.
 
je débute en c et j'aimerais faire un truc propre, sans warnings
 
merci.




 

Code :
  1. while (fgets(buffer, 256, statefile) != NULL) {
  2.  if ( (right = strstr(buffer, "prog" ))) {
  3. ...
  4. }

 


---------------
Le Tyran
n°184196
monokrome
nocturne
Posté le 27-07-2002 à 12:06:15  profilanswer
 

je te remercie
 :jap:

n°184938
Musaran
Cerveaulté
Posté le 29-07-2002 à 02:51:13  profilanswer
 

Tu fais une affectation dans un if, ce qui est très souvent une erreur = au lieu de ==, d'où le warning.
 
Si c'est vraiment ton intention, il faut être explicite.

Code :
  1. if(     (right = strstr(buffer, "prog" ))!=NULL )
  2. if( bool(right = strstr(buffer, "prog" ))       ) //ou int
  3. if(     (right = strstr(buffer, "prog" ))       )
  4. if(     (right = strstr(buffer, "prog" ))==true ) //mauvais



---------------
Bricocheap: Montage de ventilo sur paté de mastic silicone

Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Programmation
  C++

  warning: suggest parentheses around assignment used as truth value

 

Sujets relatifs
gcc warningJ'ai un WARNING en PHP : cannot header ??????
[XML XSL] value-of select="$variable" ?...[XML] XSL: faire un value-of de l'attribut d'un élément...?
[javascript] Value et Input Radio...[PHP] Warning sur fopen()
Question en C : Warning à la con[MySQL] Warning: MySQL: Too many open links (1)
mise en évidence des parenthèses en php[PHP] Warning: Unable to find ftpbuf 1 in ....................
Plus de sujets relatifs à : warning: suggest parentheses around assignment used as truth value


Copyright © 1997-2022 Hardware.fr SARL (Signaler un contenu illicite / Données personnelles) / Groupe LDLC / Shop HFR