<div dir="ltr"><div class="gmail_quote"><div dir="ltr">On Fri, Oct 6, 2017 at 11:04 AM Roy Marples <<a href="mailto:roy@marples.name">roy@marples.name</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On 05/10/2017 23:14, Kevin Lyda wrote:<br>
> That's not actually correct in practice.<br>
And top posting is?<br></blockquote><div><br></div><div>Yes. It is. We lost that battle, sorry. If it worries you, t-prot is a thing.</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Interesting that you assume I use bash and gcc.<br>
This is more portable.<br>
for f in foo bar; do cc -S $f.c; done<br></blockquote><div><br></div><div>I use zsh actually, and you figured out what I meant. Neither version will work in csh style shells. And an odd complaint about a shortcut here, since later you claim more text makes it harder to read. Also I specified gcc specifically because I had only tested with gcc - though from past experience I know modern compilers like clang, icc and others also do such optimisation.</div><div><br></div><div>Also you removed the -O2 that I had in there.</div><div> <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Now, if I do apply -O2 then clang (my system compiler) does indeed<br>
optimise it away.<br>
What is worring is that even with -O0 or no -O gcc *always* optimises it<br>
away. What if I want to call the function to be called regardless?<br></blockquote><div><br></div><div>Ugh, and my tests with gcc -O0 were actually with clang because Apple links gcc to clang. Checking gcc -O0 on Linux shows that it does optimize even at -O2.</div><div><br></div><div>Right, so to get foo.c to actually call strlen with gcc:</div><div><br></div><div>gcc -fno-builtin-strlen -S foo.c </div><div><br></div><div>or more generically:</div><div><br></div><div>gcc -fno-builtin -S foo.c </div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Spoken like a man who has never dealt with compiler issues!<br></blockquote><div><br></div><div>A rather funny comment since I'm currently dealing with multiple compiler issues.</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">if (strlen(foo) != 0)<br>
if the function to calculate the length of the string is not zero<br>
<br>
if (*foo != '\0')<br>
if the first character of the string is not NUL<br>
<br>
I'm having a hard time beliving that the former is more readable AND<br>
just as performant.<br>
It has more text for the brain to digest and a man page to read per<br>
platform.<br></blockquote><div><br></div><div>Where "more text" is four characters and replaces symbols for words that are easy for the eye to skim. Maybe I've lead a sheltered career for the past three decades, but I don't really recall a lot of APL shops in my travels.</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Or are you going to assume that gcc is the only compiler ever used anywhere?<br></blockquote><div><br></div><div>Nope. Never do. Though I do like it a great deal more than VMS's C compiler. I do wish Apple wouldn't point gcc at clang though.</div><div><br></div><div>Regardless, the dnsmasq Makefile sets -O2 in its CFLAGS so gcc or clang or, as I said previously, any modern C compiler, it will optimise out the strlen call and the strlen call is easier to read.</div><div><br></div><div>Kevin</div></div></div>