On 10/18/2011 12:50 PM, Oleg Goldshmidt wrote:
I understood that, and it's still unstable. Since if some young team member
not aware of the $Id: trick, will write:
log($Id: %d $Name: %s\n,id,name)
ident will return garbage.
Someone may alter keyword expansions just before the build, too.
On Tue, Oct 18, 2011 at 1:50 PM, Oleg Goldshmidt p...@goldshmidt.org wrote:
I didn't understand how, eg, my C++ scheme don't work. I think it should
work even if you're including the $Id$ strings in the headers files.
Apart from the fact that you assume that main.cc is mine (what if my
Shachar Shemesh shac...@shemesh.biz writes:
I understand why these keywords were useful for CVS/RCS, where each
file had its own version number. When working with SVN, however, a
single number uniquely identifies the entire source tree. Why not
have that one number and get it done with?
I
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
I guess that it doesn't apply to libraries, which must include this global
variable.
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);...}
The only trick the optimizer can play here,
On Tue, Oct 18, 2011, Elazar Leibovich wrote about Re: Newer gcc swallow
version control keywords:
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);...}
The point in Oleg's trick
On Tue, Oct 18, 2011 at 11:50 AM, Nadav Har'El n...@math.technion.ac.ilwrote:
On Tue, Oct 18, 2011, Elazar Leibovich wrote about Re: Newer gcc swallow
version control keywords:
Excuse the idiotic solution, but can't you just add an option to print it
out?
int main(int argc,char**argv
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
On Tue, Oct 18, 2011 at 11:50 AM, Nadav Har'El n...@math.technion.ac.il wrote:
One reason that nobody really cares about this trick any more is that it has
become MUCH LESS IMPORTANT on modern version control systems, e.g., Subversion
or Git, where there is a single version number (or version
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.orgwrote:
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
I understood that, and it's still unstable. Since if some young team member
not aware of the $Id: trick, will write:
log($Id: %d $Name: %s\n,id,name)
ident will return garbage.
Someone may alter keyword expansions just before the build, too.
If you have documented way to get the ident
On Tue, Oct 18, 2011 at 12:50 PM, Oleg Goldshmidt p...@goldshmidt.orgwrote:
I understood that, and it's still unstable. Since if some young team
member
not aware of the $Id: trick, will write:
log($Id: %d $Name: %s\n,id,name)
ident will return garbage.
Someone may alter keyword
On Tue, Oct 18, 2011 at 12:57 PM, Elazar Leibovich elaz...@gmail.com wrote:
On Tue, Oct 18, 2011 at 12:50 PM, Oleg Goldshmidt p...@goldshmidt.org
wrote:
Someone may alter keyword expansions just before the build, too.
I'm not sure I understand your comment. Are you telling that this is
On Tue, Oct 18, 2011, Elazar Leibovich wrote about Re: Newer gcc swallow
version control keywords:
fileversion.h:
class FileVersion {FileVersion(const string v){__files.push_back(v);}};
foo.cc:
static const FileVersion foo($id$);
Well, basically you're showing that unlike C where a static
On Tue, Oct 18, 2011 at 2:25 PM, Nadav Har'El n...@math.technion.ac.il wrote:
On Tue, Oct 18, 2011, Elazar Leibovich wrote about Re: Newer gcc swallow
version control keywords:
fileversion.h:
class FileVersion {FileVersion(const string v){__files.push_back(v);}};
foo.cc:
static const
On Tue, Oct 18, 2011, Oleg Goldshmidt wrote about Re: Newer gcc swallow
version control keywords:
No, no, it is optimized out - Elazar tried to make a global non-static
(non-file-scope) variable (non-constant) that *is* used (by the main()
routine - and may be used, including modification
I understood his intention differently. He used his trick not just in main,
but also in every file in his example.
Yes, it does not matter. As I said, he adds an attempt to *refer* to
the global variable in main() to make it used.
Did you actually check this in C++?
Yes.
But in any case
On Tue, Oct 18, 2011, Oleg Goldshmidt wrote about Re: Newer gcc swallow
version control keywords:
It was about C++. C and C++ compilers behave the same.
I was very surprised to discover that this is indeed the case. I think this
is a BUG. For example, consider this C++ program
On Tue, Oct 18, 2011 at 4:04 PM, Nadav Har'El n...@math.technion.ac.il wrote:
On Tue, Oct 18, 2011, Oleg Goldshmidt wrote about Re: Newer gcc swallow
version control keywords:
It was about C++. C and C++ compilers behave the same.
I was very surprised to discover that this is indeed the case
On Tue, Oct 18, 2011, Nadav Har'El wrote about Re: Newer gcc swallow version
control keywords:
On Tue, Oct 18, 2011, Oleg Goldshmidt wrote about Re: Newer gcc swallow
version control keywords:
It was about C++. C and C++ compilers behave the same.
I was very surprised to discover
On Mon, Oct 17, 2011 at 10:21 PM, Oleg Goldshmidt p...@goldshmidt.org wrote:
Nadav Har'El n...@math.technion.ac.il writes:
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
On Tue, Oct 18, 2011 at 12:49 PM, Elazar Leibovich elaz...@gmail.com wrote:
But you shouldn't care that they're having a file scope, do you?
Of course I do. Just as one example: suppose that this/dir/foo.c and
that/other/module/bar.c both #include xyzzy.h. I want to catch a
build system bug
Hi,
I have a gcc-related question. Problematic platform is Fedora 15 with
gcc 4.6.1, as well as Fedora 14 with gcc 4.5.1.
I am used to keeping RCS/CVS/SVN keywords (e.g., $Id$) in all my code.
In the case of C/C++ this normally amounts to
static const char foo_src_id[] = $Id$;
in the source
Hi Oleg,
On Mon, Oct 17, 2011 at 06:29:58PM +0200, Oleg Goldshmidt wrote:
...
Now, put the above line in a C or C++ file, say foo.cc, and do the
following:
$ g++ -g -O2 foo.cc -c -o foo.o
$ ident foo.o
foo.o:
$Id: foo.cc 673 2011-10-17 09:48:11Z oleg $
This works up to and
On Mon, Oct 17, 2011, Oleg Goldshmidt wrote about Newer gcc swallow version
control keywords:
static const char foo_src_id[] = $Id$;
I remember many years ago (when I was probably still using SCCS with its %..%
macros, and SCCS's what(1) instead of ident(1)), there was already an argument
On 10/17/2011 06:29 PM, Oleg Goldshmidt wrote:
Hi,
I have a gcc-related question. Problematic platform is Fedora 15 with
gcc 4.6.1, as well as Fedora 14 with gcc 4.5.1.
I am used to keeping RCS/CVS/SVN keywords (e.g., $Id$) in all my code.
In the case of C/C++ this normally amounts to
Nadav Har'El n...@math.technion.ac.il writes:
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
is not a GCC extension,
Baruch Siach bar...@tkos.co.il writes:
The -O2, as well as -O and -Os, gcc options enable a set of specific
optimizations that can each be turned off. The full list is at
http://gcc.gnu.org/onlinedocs/gcc-4.6.1/gcc/Optimize-Options.html. Just
go over this list and disable each optimization,
Shachar Shemesh shac...@shemesh.biz writes:
Leaving aside the question of whether that is a good idea
This saved my butt enough times in the past that I think it is ;-)
- did you try
changing that to:
static const volatile char foo_src_id[] = $Id$;
Hmm... const volatile hadn't occurred to
On 10/17/2011 10:29 PM, Oleg Goldshmidt wrote:
- did you try
changing that to:
static const volatile char foo_src_id[] = $Id$;
Hmm... const volatile hadn't occurred to me before, but I have just
tried it and it did not work.
Just tested it myself. It does, indeed, not work. I wonder why?
Shachar Shemesh shac...@shemesh.biz writes:
Just tested it myself. It does, indeed, not work. I wonder why?
Seems like it SHOULD work. After all, that's what volatile is for,
right?
I suspected that const was more important than volatile, but it looks
(after I removed const) that what
Shachar Shemesh wrote on Mon, Oct 17, 2011 at 22:47:49 +0200:
On 10/17/2011 10:29 PM, Oleg Goldshmidt wrote:
- did you try
changing that to:
static const volatile char foo_src_id[] = $Id$;
Hmm... const volatile hadn't occurred to me before, but I have just
tried it and it did not work.
Nadav Har'El n...@math.technion.ac.il writes:
#if (__GNUC__ = 4) (__GNUC_MINOR__ 4)
#define USED(x) x __attribute__((used))
#else
#define USED(x) x
#endif
#define IDENT(x) static const char USED(foo_src_id[]) = x;
and then in each file just do
http://gcc.gnu.org/ml/gcc/2005-04/msg01429.html
I do have three suggestions for you:
1) The current way to tell the compiler not to throw away
apparently-unused data is __attribute__((used)), like this:
static const char __attribute__((used)) rcs_sccs_id[] =
$Id: @(#)%M%
34 matches
Mail list logo