<div dir="ltr"><div>I do understand the purpose of optimisation. Thanks.</div><div><br></div><div>If you read the original posting you will see why.</div><div><br></div><div>All I want to do is printf the level so I have that in the logs.</div><div><br></div><div>With a Makefile built system it is reasonably easy by passing in a string with -D, but is a pain with an Eclipse managed system (as I am working with at the moment).<br></div><div><br></div><div>Something along the lines of:</div><div><br></div><div>OPT_LEVEL = -Os</div><div><br></div><div>gcc -c $(OPT_LEVEL) -DOPT_LEVEL_STRING="$(OPT_LEVEL)"</div><div><br></div><div>and in the C file</div><div><br></div><div>const char *opt_string=OPT_LEVEL_STRING;<br></div><div><br></div><div><br></div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Jul 1, 2020 at 9:34 AM Bevin Brett <<a href="mailto:bevin_brett@hotmail.com">bevin_brett@hotmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div dir="ltr">
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
I am interested in why your code cares about optimization level.<br>
<br>
<span style="color:rgb(0,0,0);font-family:Calibri,Helvetica,sans-serif;font-size:12pt">Most modern compilers have many different optimizations controlled by command line switches, and they also package them into a few sets for easy usage</span><br>
</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
They can be summarized as:</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
optimizations that have leave a very close source to instruction set and data placement correspondence, for ease of debugging</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
these are always all on by default</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
safe optimizations that shrink the instructions size<br>
<br>
safe optimizations that expand the instructions size and usually decrease execution<br>
<br>
unsafe optimizations like the above - these may cause crashes or bad answers unless your program meets some additional requirements<br>
<br>
/Bevin</div>
</div>
_______________________________________________<br>
Chchrobotics mailing list <a href="mailto:Chchrobotics@lists.ourshack.com" target="_blank">Chchrobotics@lists.ourshack.com</a><br>
<a href="https://lists.ourshack.com/mailman/listinfo/chchrobotics" rel="noreferrer" target="_blank">https://lists.ourshack.com/mailman/listinfo/chchrobotics</a><br>
Mail Archives: <a href="http://lists.ourshack.com/pipermail/chchrobotics/" rel="noreferrer" target="_blank">http://lists.ourshack.com/pipermail/chchrobotics/</a><br>
Meetings usually 3rd Monday each month. See <a href="http://kiwibots.org" rel="noreferrer" target="_blank">http://kiwibots.org</a> for venue, directions and dates.<br>
When replying, please edit your Subject line to reflect new subjects.</blockquote></div>