<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=utf-8"><meta name=Generator content="Microsoft Word 15 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
.MsoChpDefault
{mso-style-type:export-only;}
@page WordSection1
{size:612.0pt 792.0pt;
margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
{page:WordSection1;}
--></style></head><body lang=EN-NZ link=blue vlink="#954F72"><div class=WordSection1><p class=MsoNormal><span lang=EN-US>This might help:<o:p></o:p></span></p><p class=MsoNormal><a href="https://math-linux.com/c/faq-c/faq-c-gcc-g/article/gcc-g-how-to-dump-all-preprocessor-definitions">https://math-linux.com/c/faq-c/faq-c-gcc-g/article/gcc-g-how-to-dump-all-preprocessor-definitions</a><o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><span lang=EN-US>$ touch foo.h<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>$ gcc -E -Os -dM foo.h | grep OP<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>#define __OPTIMIZE__ 1<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>#define __OPTIMIZE_SIZE__ 1<o:p></o:p></span></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Quick experiment looks like you get the fine grain optimisations rather than O1,2,3 etc.<o:p></o:p></p><p class=MsoNormal>Andy</p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Sent from <a href="https://go.microsoft.com/fwlink/?LinkId=550986">Mail</a> for Windows 10</p><p class=MsoNormal><o:p> </o:p></p><div style='mso-element:para-border-div;border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0cm 0cm 0cm'><p class=MsoNormal style='border:none;padding:0cm'><b>From: </b><a href="mailto:cdhmanning@gmail.com">Charles Manning</a><br><b>Sent: </b>Sunday, 28 June 2020 6:48 PM<br><b>To: </b><a href="mailto:chchrobotics@lists.ourshack.com">Christchurch Robotics</a><br><b>Subject: </b>[chbot] gcc experts: Is there a flag/symbol available to see current optimisations?</p></div><p class=MsoNormal><o:p> </o:p></p><div><div><p class=MsoNormal>Hi All</p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>I want to be able to tell in some logs what optimisation level was used to compile some code.</p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>eg. </p></div><div><p class=MsoNormal> printf("This code was optimised with %s\n", omptimisation_string());</p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>And this would print:</p></div><div><p class=MsoNormal>"This code was optimised with -Os\n" or whatever.</p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>Does anyone know of such a thing in gcc?</p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>Thanks.</p></div></div><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><o:p> </o:p></p></div></body></html>