First, please see my last email to Nadav, which discuss a lot of the details.
On Tue, Oct 18, 2011 at 12:41 PM, Oleg Goldshmidt <p...@goldshmidt.org>wrote: > On Tue, Oct 18, 2011 at 11:16 AM, Elazar Leibovich <elaz...@gmail.com> > wrote: > > I guess that it doesn't apply to libraries, which must include this > global > > variable. > > The whole point is that the constants are not global but have file > scope. Therefore the optimizer can figure out they are not really > used. > But you shouldn't care that they're having a file scope, do you? 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. > > > Excuse the idiotic solution, but can't you just add an option to print it > > out? > > int main(int argc,char**argv) {if (argc == 2 && strcmp(argv[1],"--ident") > > puts(ident);...} > > This is fine for the main() routine of a regular application. What > about other files? Headers? What about daemons that have no I/O? > It doesn't matter. The daemon will still not have output unless invoked with "--ident". You shouldn't care about that, should you? 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? > > > It seems like a good idea anyhow, to have a stable way of extracting this > > ident string from the executable > > That's the function of ident(1) - and that's what is not working > because the compiler eats the strings. > See my reply to Nadav. I meant unstable because of "$Id: %d, $Name: %s" will also be printed. > > > (what happens for instance if by accident > > you have rcsident and rcs_ident? How would you know from the stripped > > executable which one to trust?). > > It's the version control system's function to expand the keywords with > the right data - if I have multiple strings they will be consistent. > My bad, I thought it's supposed to be an application scope version string.
_______________________________________________ Linux-il mailing list Linux-il@cs.huji.ac.il http://mailman.cs.huji.ac.il/mailman/listinfo/linux-il