🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

4 total messages Started by STIOO Fri, 04 Aug 1995 19:53
problem with assertions
#1599
Author: STIOO
Date: Fri, 04 Aug 1995 19:53
17 lines
708 bytes
   ...
   
   BOOL
      bSuccess = bTrySomething();

   assert(bSuccess);   // I kwnow it must be a success.

   ...


   When I remove the assert statement  (undefining a keyword) I get 
a compiler warning: "bSuccess declared but not used".

   Is there another writing style that avoids such a message?

   Louis Lecomte
   stioo project.
Re: problem with assertions
#1650
Author: Nick Mein
Date: Mon, 07 Aug 1995 23:44
25 lines
1130 bytes
[Followups directed to comp.lang.c++]

STIOO (stioo@ift.ulaval.ca) wrote:
    
:    BOOL bSuccess = bTrySomething();
:    assert(bSuccess);   // I kwnow it must be a success.

:    When I remove the assert statement  (undefining a keyword) I get 
:    a compiler warning: "bSuccess declared but not used".

:    Is there another writing style that avoids such a message?

Microsoft's MFC defines a VERIFY macro which works as an assert, but
when _debug is undefined the expression is still evaluated for its side 
effects. Ie, you would use:

     verify(bTrySomething());

--
Nick Mein
MSc Student
Dept of Computer Science
University of Otago
Dunedin
New Zealand.
Re: problem with assertions
#1766
Author: J. Kanze
Date: Tue, 15 Aug 1995 02:41
31 lines
1571 bytes
STIOO (stioo@ift.ulaval.ca) wrote:
|>    ...
|>
|>    BOOL
|>       bSuccess = bTrySomething();

|>    assert(bSuccess);   // I kwnow it must be a success.

|>    ...


|>    When I remove the assert statement  (undefining a keyword) I get
|> a compiler warning: "bSuccess declared but not used".

|>    Is there another writing style that avoids such a message?

Get a compiler that understands C++.  The ``declared but not used''
warning is not applicable to objects; the compiler should know enough to
not generate it if the object has a constructor or a destructor.

While waiting: pipe the compiler output through grep -v 'declared but
not used'.
--
James Kanze           (+33) 88 14 49 00          email: kanze@gabi-soft.fr
GABI Software, Sarl., 8 rue des Francs Bourgeois, 67000 Strasbourg, France
Conseils en informatique industrielle--
--Beratung in industrieller Datenverarbeitung
---
[ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
Contact address: std-c++-request@ncar.ucar.edu.  The moderation policy
is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
Re: problem with assertions
#1802
Author: Shankar Unni
Date: Tue, 22 Aug 1995 08:17
24 lines
1547 bytes
J. Kanze (kanze@gabi-soft.fr) wrote:

> |>    BOOL
> |>       bSuccess = bTrySomething();

> Get a compiler that understands C++.  The ``declared but not used''
> warning is not applicable to objects;

Ah, but "bSuccess" is not an object: it's a bool. The declaration and
assignment to bSuccess is indeed superfluous if bSuccess is never used
again, as it has no effects unless bSuccess were a volatile..

If we're now saying that a compiler should *never* warn a user about
something which is declared but not used (or in this case, "set but not
used"), because in some cases the user *may* be doing something
"reasonable", then that's a different kettle of fish..
--
Shankar Unni				E-Mail:	shankar@sgi.com
Silicon Graphics Inc.			Phone:	+1-415-390-2072
URL:	http://reality.sgi.com/employees/shankar
---
[ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  Contact address: std-c++-request@ncar.ucar.edu.  The moderation policy
  is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads