summaryrefslogtreecommitdiff
path: root/docs/ACE-guidelines.html
diff options
context:
space:
mode:
authorlevine <levine@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1998-12-17 18:56:07 +0000
committerlevine <levine@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1998-12-17 18:56:07 +0000
commit22ad6cf5bc0d2e15d3f2e81d6e0d97f472a6068a (patch)
treeb86ee1b01cfa4d8fb4c400acf571f5561e558b4b /docs/ACE-guidelines.html
parent3af262065b5b5fb2d97d5f7f5053979d669722d1 (diff)
downloadATCD-22ad6cf5bc0d2e15d3f2e81d6e0d97f472a6068a.tar.gz
added warning about side effects in ACE_DEBUG statements
Diffstat (limited to 'docs/ACE-guidelines.html')
-rw-r--r--docs/ACE-guidelines.html19
1 files changed, 15 insertions, 4 deletions
diff --git a/docs/ACE-guidelines.html b/docs/ACE-guidelines.html
index 1ed124ceb31..ecaca41b7e1 100644
--- a/docs/ACE-guidelines.html
+++ b/docs/ACE-guidelines.html
@@ -727,9 +727,9 @@ bgcolor="#ffffff">
<li>Be <em>very</em> careful with <code>ACE_ASSERT</code>. It
must only be used to check values; it may never be used to
- wrap a function call, or any other statement. That's because
- the statement will disappear when ACE_NDEBUG is enabled. For
- example, this code is BAD:
+ wrap a function call, or contain any other side effect. That's
+ because the statement will disappear when ACE_NDEBUG is enabled.
+ For example, this code is BAD:
<pre>
ACE_ASSERT (this-&gt;next (retv) != 0); // BAD CODE!
</pre>
@@ -740,8 +740,19 @@ bgcolor="#ffffff">
int result = this-&gt;next (retv);
ACE_ASSERT (result != 0);
ACE_UNUSED_ARG (result);
+ </pre><p>
+
+ <li>Never put side effects in <code>ACE_DEBUG</code> code:
+ <pre>
+ ACE_DEBUG ((LM_DEBUG,
+ "handling signal: %d iterations left\n",
+ --this-&gt;iterations_)); // BAD CODE!
</pre>
-<p>
+
+ Note that this won't work correctly if <code>ACE_NDEBUG</code> is
+ defined, for the same reason that having side-effects in
+ <code>ACE_ASSERT</code>s won't work either, <em>i.e.</em>, because
+ the code is removed.<p>
</ul>