<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix"><br>
We are using it for several things -- you can do the mechanism
inside the makefile to "turn on" and turn off portions of your
code at compile time. That is what we were talking about last
week. The thing I was showing you at the end of class today was
different -- that was called "ifdef wrapping" a function so that
there is only once instance of a method defined at link time.
This has to be done when you use segmented makefiles. <br>
<br>
Think about it, if you have a segmented (and subsequently lots of
files to "make"), each of this will probably have a list of files
to include.<br>
<br>
C/C++ doesn't want to see things defined multiple times, so we do
the <br>
<br>
<pre><code class="language-h hljs "><span id="LC2" class="line"><span class="hljs-preprocessor">#ifndef BOX_H</span></span>
<span id="LC3" class="line"><span class="hljs-preprocessor">#<span class="hljs-keyword">define</span> BOX_H
my c++ class definition
#endif
</span></span></code></pre>
<br>
I may have multiple files that include the one above -- and that
have to include it to even compile -- but when it comes time to
link all of the object files together, only one instance is
needed. The things above and below the code are used by the
linker in this scenario -- if there not a BOX_H defined, the
define above will define the BOX_H symbol (and the code will be
compiled and placed in the object space). When this code is
encoutered in another include file, the BOX_H symbol will already
be defined and the code will not be compiled (which would cause a
compile error because all of the varialbles and stuff have already
been defined).<br>
<br>
The pre-processor is very powerful.<br>
<br>
<br>
<br>
On 10/30/2014 05:34 PM, Kevin L. Long wrote:<br>
</div>
<blockquote
cite="mid:C40B2F181831EF44A88CD73525827803130CFB7932@MERCERMAIL.MercerU.local"
type="cite">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<style type="text/css" style="display:none"><!-- p { margin-top: 0px; margin-bottom: 0px; }--></style>
<p>I should have phrased that better. I meant what are we using
it for? It says we're using it to choose between program 1 and
2, but I got the impression in class (maybe I misunderstood)
that we just used the terminal for that.<br>
</p>
<div style="color: rgb(33, 33, 33);">
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="divRplyFwdMsg" dir="ltr"><font style="font-size:11pt"
color="#000000" face="Calibri, sans-serif"><b>From:</b>
Andrew J. Pounds <a class="moz-txt-link-rfc2396E" href="mailto:pounds_aj@mercer.edu"><pounds_aj@mercer.edu></a><br>
<b>Sent:</b> Thursday, October 30, 2014 5:07 PM<br>
<b>To:</b> Kevin L. Long<br>
<b>Subject:</b> Re: Ifdef</font>
<div> </div>
</div>
<div>
<div class="moz-cite-prefix">On 10/30/2014 04:51 PM, Kevin L.
Long wrote:<br>
</div>
<blockquote type="cite">
<style type="text/css" style="">
<!--
p
        {margin-top:0;
        margin-bottom:0}
-->
</style>
<p>Exactly in what manner is ifdef supposed to be used?<br>
</p>
</blockquote>
<br>
<a moz-do-not-send="true" class="moz-txt-link-freetext"
href="http://www.cplusplus.com/doc/tutorial/preprocessor/">http://www.cplusplus.com/doc/tutorial/preprocessor/</a><br>
<pre class="moz-signature" cols="72">--
Andrew J. Pounds, Ph.D. (<a moz-do-not-send="true" class="moz-txt-link-abbreviated" href="mailto:pounds_aj@mercer.edu">pounds_aj@mercer.edu</a>)
Professor of Chemistry and Computer Science
Mercer University, Macon, GA 31207 (478) 301-5627
<a moz-do-not-send="true" class="moz-txt-link-freetext" href="http://faculty.mercer.edu/pounds_aj">http://faculty.mercer.edu/pounds_aj</a>
</pre>
</div>
</div>
</blockquote>
<br>
<br>
<pre class="moz-signature" cols="72">--
Andrew J. Pounds, Ph.D. (<a class="moz-txt-link-abbreviated" href="mailto:pounds_aj@mercer.edu">pounds_aj@mercer.edu</a>)
Professor of Chemistry and Computer Science
Mercer University, Macon, GA 31207 (478) 301-5627
<a class="moz-txt-link-freetext" href="http://faculty.mercer.edu/pounds_aj">http://faculty.mercer.edu/pounds_aj</a>
</pre>
</body>
</html>