home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / lang / c / 20023 < prev    next >
Encoding:
Internet Message Format  |  1993-01-21  |  2.8 KB

  1. Path: sparky!uunet!crdgw1!rdsunx.crd.ge.com!bart!volpe
  2. From: volpe@bart.NoSubdomain.NoDomain (Christopher R Volpe)
  3. Newsgroups: comp.lang.c
  4. Subject: Multi statement macro (Was: Re: Collection Virus Retract
  5. Message-ID: <1993Jan21.182528.5470@crd.ge.com>
  6. Date: 21 Jan 93 18:25:28 GMT
  7. References: <1993Jan14.214829.119753@marshall.wvnet.edu> <1993Jan20.201726.6015@Newbridge.COM>
  8. Sender: volpe@bart (Christopher R Volpe)
  9. Reply-To: volpe@ausable.crd.ge.com
  10. Organization: GE Corporate Research & Development
  11. Lines: 65
  12. Nntp-Posting-Host: bart.crd.ge.com
  13.  
  14. Lynne-
  15.  
  16. Subject: Re: Collection Virus Retract
  17. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  18. What does this subject have to do with your question below?
  19.  
  20. In article <1993Jan20.201726.6015@Newbridge.COM>, lynnem@Newbridge.COM (Lynne Martin) writes:
  21. |> In article <1993Jan14.214829.119753@marshall.wvnet.edu> rcbi20@marshall.wvnet.edu writes:
  22. |> >--  Retraction an my apologies for my previous postings.
  23. |> >
  24. |> >    I have receive many flames about my Collection of Viruses for Reasreach
  25. |> >posting and I would like to apologies to all who found my posttings a problem. 
  26. |> >After a long talk with my POSTMASTER I realized how stupid the posting was.  I
  27. |> >would like to thank those who wrote and informed me on the rules of 
  28. |> >internet althought ingorance is no reason to break the rules.  I'am very sorry!
  29. |> >We are going to continue our research but we will not ask for code like I did.
  30. |> >
  31. |> >-- 
  32. |> >                        Jason Haught (The Master)
  33. |> >
  34. |> >E-Mail Addresses:
  35. |> >
  36. |> >    RCBI20@Marshall.WVnet.edu (Internet) / RCBI20@Marshall (Bitnet)
  37. |> >    CIS0201@Muvms2.WVnet.edu  (Internet)
  38. |> >    @Byrd.MU.WVnet.edu:JHaught@RCBINS.MU.WVnet.edu (Internet)
  39. |> >    Jason@Quayle.MU.WVnet.edu (Internet)
  40.  
  41. What does the article you included above have to do with your question
  42. below?
  43.  
  44. |> 
  45. |> In the Comp.lang.c FAQ, question 6.3 asks what is the best way 
  46. |> to write a multi-statement cpp macro and the answer is:
  47. |> 
  48. |> #define Func() do {stmt1; stmt2; ... } while (0)
  49. |> 
  50. |> My problem is that when lint sees one of these macros it spits 
  51. |> out the  following warnings:
  52. |> 
  53. |> warning:  constant argument to NOT
  54. |> warning:  constant in conditional context
  55. |> 
  56. |> Can anyone tell me why lint generates the first warning, and if you've
  57.  
  58. Well the first warning may be due to the fact that "while(a)" is
  59. equivalent to "while(!(a==0))", and it may actually be doing a conversion
  60. internally. So, it sees your condition as "while (!(0==0)). There's
  61. the argument to the NOT operator.
  62.  
  63. |> figured out a way to prevent lint from generating either warning?
  64.  
  65. Preventing the warning is a bit tougher. The warning is correct, from lint's
  66. point of view. You might have better luck with a different form of the 
  67. multi-statement macro:
  68.  
  69. #define Func() if (1) {stmt1; stmt2; ...} else
  70.  
  71. Hope this helps...
  72.  
  73. -Chris
  74. -- 
  75. ==================
  76. Chris Volpe
  77. G.E. Corporate R&D
  78. volpecr@crd.ge.com
  79.