<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"><<a href="mailto:pub@goldshmidt.org">pub@goldshmidt.org</a>></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 <<a href="mailto:elazarl@gmail.com">elazarl@gmail.com</a>> wrote:<br>
> I guess that it doesn't apply to libraries, which must include this global<br>
> 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't care that they're having a file scope, do you?</div><div>So I think it'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>
> Excuse the idiotic solution, but can't you just add an option to print it<br>
> out?<br>
> int main(int argc,char**argv) {if (argc == 2 && strcmp(argv[1],"--ident")<br>
> 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't matter. The daemon will still not have output unless invoked with "--ident". You shouldn'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'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>
> It seems like a good idea anyhow, to have a stable way of extracting this<br>
> ident string from the executable<br>
<br>
</div>That's the function of ident(1) - and that'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 "$Id: %d, $Name: %s" 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>
> (what happens for instance if by accident<br>
> you have rcsident and rcs_ident? How would you know from the stripped<br>
> executable which one to trust?).<br>
<br>
</div>It's the version control system'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's supposed to be an application scope version string.</div><div><br></div></div><br></div>