<div dir="ltr">First, please see my last email to Nadav, which discuss a lot of the details.<br><br><div class="gmail_quote">On Tue, Oct 18, 2011 at 12:41 PM, Oleg Goldshmidt <span dir="ltr">&lt;<a href="mailto:pub@goldshmidt.org">pub@goldshmidt.org</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div class="im">On Tue, Oct 18, <a href="tel:2011" value="+9722011">2011</a> at 11:16 AM, Elazar Leibovich &lt;<a href="mailto:elazarl@gmail.com">elazarl@gmail.com</a>&gt; wrote:<br>

&gt; I guess that it doesn&#39;t apply to libraries, which must include this global<br>
&gt; variable.<br>
<br>
</div>The whole point is that the constants are not global but have file<br>
scope. Therefore the optimizer can figure out they are not really<br>
used.<br></blockquote><div><br></div><div>But you shouldn&#39;t care that they&#39;re having a file scope, do you?</div><div>So I think it&#39;s an OK solution to allow them have application scope. Am I correct? See my C++ implementation in the reply to Nadav.</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im"><br>
&gt; Excuse the idiotic solution, but can&#39;t you just add an option to print it<br>
&gt; out?<br>
&gt; int main(int argc,char**argv) {if (argc == 2 &amp;&amp; strcmp(argv[1],&quot;--ident&quot;)<br>
&gt; puts(ident);...}<br>
<br>
</div>This is fine for the main() routine of a regular application. What<br>
about other files? Headers? What about daemons that have no I/O?<br></blockquote><div><br></div><div>It doesn&#39;t matter. The daemon will still not have output unless invoked with &quot;--ident&quot;. You shouldn&#39;t care about that, should you?</div>
<div>In case of libraries (.o, .a, .so), I think that if you expose the const char* variable, the optimizer can&#39;t eat it away. How would it knows no user of the library uses it?</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

<div class="im"><br>
&gt; It seems like a good idea anyhow, to have a stable way of extracting this<br>
&gt; ident string from the executable<br>
<br>
</div>That&#39;s the function of ident(1) - and that&#39;s what is not working<br>
because the compiler eats the strings.<br></blockquote><div><br></div><div>See my reply to Nadav. I meant unstable because of &quot;$Id: %d, $Name: %s&quot; will also be printed.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

<div class="im"><br>
&gt; (what happens for instance if by accident<br>
&gt; you have rcsident and rcs_ident? How would you know from the stripped<br>
&gt; executable which one to trust?).<br>
<br>
</div>It&#39;s the version control system&#39;s function to expand the keywords with<br>
the right data - if I have multiple strings they will be consistent.<br></blockquote><div><br></div><div>My bad, I thought it&#39;s supposed to be an application scope version string.</div><div><br></div></div><br></div>