On Mon, Oct 17, 2011, Oleg Goldshmidt wrote about "Re: Newer gcc swallow version control keywords": > > In any case, because there was always a fear that the compiler might > > optimize these out, someone invented a new directive, #ident, as in: > > > > #ident "$Id$" > > This has always been there, but it has never been standard, AFAIK. It
"Always" is always a relative term, when we're talking about a programming language (C) invented 40 years ago. I'm pretty sure #ident has indeed been around for around 20 years. About standardization, you may be right: I just checked and sadly I can't find "#ident" anywhere in the C99 standard. But that being said, I wonder if in practice, on actual computers of interest today, it will work. I just checked on my Fedora 15, Gcc 4.6.1, and it works well. Sadly, all the dozen other Unix variants to which I used to have access, have gone the way of the dodo, so I can't check this on any other C compiler. > is not a GCC extension, either. Most preprocessors don't barf on > directives they do not understand, but they may simply ignore #ident > which will lead to the same behaviour that I do not want. They *may* ignore #ident, but like I said, #ident has been around for ages, and may actually work on many if not all compilers. Like I said, it does on gcc. I checked, and it seems it generates assemly that looks like: .ident "$Id: hello $" Which I guess GNU AS supports, seeing that the ident string appears in the object file and in the final executable - even if compiled with -O2. > When you say that it has worked for you with all sorts of compilers do > you mean that it actually produced the $Id$ string with ident or that > it didn't break? Whenever I checked, it worked in the sense of generating code. But I was never a big fan of what(1) and ident(1) like you, so I haven't checked this in ages. > I was wondering whether someone would catch my little mischief: this > bug report complains about the same effect in a slightly different > situation. Even with older GCC the $Id$ string is not there with just > -O2, but it is with "-g -O2" (cf. my original posting - I put the > exact command line there for a reason). > > Yes, I agree with the opinion that -fkeep-static-consts should > override optimization (it is more specific), but it has never been the > case (or at least not for a very long time). I suggest you add your comments to that bug report, to make it known that people still care. Apparently, you're the last user (!?) of ident(1), so make your voice heard :-) -- Nadav Har'El | Tuesday, Oct 18 2011, n...@math.technion.ac.il |----------------------------------------- Phone +972-523-790466, ICQ 13349191 |Unix is user friendly - it's just picky http://nadav.harel.org.il |about its friends. _______________________________________________ Linux-il mailing list Linux-il@cs.huji.ac.il http://mailman.cs.huji.ac.il/mailman/listinfo/linux-il