🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.help
Article #42399

Re: How to compile in RCS identifiers?

#42399
From: Rohan LENARD
Date: Tue, 19 Dec 1995 00:00
67 lines
2822 bytes
In article <199512160821.SAA05276@gauss.adelaide.maptek.com.au>,
Rusty, Paul ,  Russell <Rusty.Russell@adelaide.maptek.com.au> wrote:
:In message <4as6dg$3ih@ets.cis.brown.edu> you write:
:> I'm trying to figure out how to best include RCS version identifier
:> strings into the various modules I'm compiling with gcc.  I've been
:> running into two problems.
:> 
:> 1) With -Wall the compiler warns about the variable being unused
:> 2) The compiler optimizes away the existence of the string
:
:Hi James,
:	I use the following piece of code:
:
:------ RcsId.h ------
:#ifdef __GNUC__
:// Use Gnu's __attribute__ keyword to suppress warning.
:#define ALT_RCSID(Id, Name) \
:	static const char RCS_ID_##Name[] __attribute__((unused)) = Id
:#else
:// Grotty method of warning suppression
:#define ALT_RCSID(Id, Name)				\
:	static const char RCS_ID_##Name[] = Id;		\
:	static void _DummyUseRCSIdFunction##Name(void)	\
:	{						\
:	  (void)_DummyUseRCSIdFunction##Name;		\
:	  (void)RCS_ID_##Name;				\
:	}
:#endif /*GNU*/
:
:#define DO_ALT_RCSID(x,y) ALT_RCSID(x,y)
:#define RCSID(Id) DO_ALT_RCSID(Id, __LINE__)
:------------------

It's amazing how people come to a similar solution ...

We are using something like this -

#ifndef FILEREVID
#ifdef __GNUG__
#define FILEREVID(f,b)  static char* f##Rcsids_ = __VERSION__ " @(#) " b; \
                void f##Ident_(char* x = f##Rcsids_);
#else
#define FILEREVID(f,b)  static char* f##Rcsids_ = "@(#)" b; \
                void f##Ident_(char* x = f##Rcsids_);
#endif  // __GNUG__
#endif  // FILEREVID

This is used something like this -

FILEREVID(Foo_cc,"$Id$");

And gives us strings like these in our code -
2.6-95q3 @(#) $Id: Signal.cls,v 1.26 1995/05/26 02:19:41 a1s unit $

Using "what" we of course get this -
	$Id: Signal.cls,v 1.26 1995/05/26 02:19:41 a1s unit $

We've found that we can catch problems with binary problems just by 
checking the compiler variant used !!

Regards,
	Rohan
-- 
----------------------------------------------------------------------------
rjl@iassf.easams.com.au	| All quotes can be attributed to my automated quote
Rohan Lenard            | writing tool.  Yours for just $19.95; and if you
+61-2-367-4555          | call now you'll get a free set of steak knives ...
Technical Details
Message-ID: <4b4mu9$afj@f111.iassf.easams.com.au>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <4as6dg$3ih@ets.cis.brown.edu> <199512160821.SAA05276@gauss.adelaide.maptek.com.au>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 11318c,64570f4dd695fd36
X-Google-Attributes: gid11318c,public
From: rjl@f111.iassf.easams.com.au (Rohan LENARD)
Subject: Re: How to compile in RCS identifiers?
Date: 1995/12/19
Message-ID: <4b4mu9$afj@f111.iassf.easams.com.au>
X-Deja-AN: 122223940
distribution: gnu
references: <4as6dg$3ih@ets.cis.brown.edu> <199512160821.SAA05276@gauss.adelaide.maptek.com.au>
organization: EASAMS (Australia) Pty Ltd
newsgroups: gnu.gcc.help