[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [XForms] FL_FIXLEVEL change (small) problem
From: |
Jens Thoms Toerring |
Subject: |
Re: [XForms] FL_FIXLEVEL change (small) problem |
Date: |
Tue, 22 Dec 2009 15:07:51 +0100 |
User-agent: |
Mutt/1.5.18 (2008-05-17) |
Hi Michal,
On Tue, Dec 22, 2009 at 12:02:11PM +0100, Michal Szymanski wrote:
> In some of my XForms apps I include a possibility to show the version of
> libraries used.
>
> The FL_FIXLEVEL define in "forms.h" has changed its "type", from an int
> (eg. 2) to a string (eg. "92sp2"). This makes it difficult to properly
> print the full version.
>
> Any idea how to programatically (either at preprocessing stage or at program
> execution) detect the type of such a macro?
Sorry that I broke something for your applications with this
change, I hadn't forseen this. Unfortunately, reverting to
the old way will break things for those that now rely on the
FIXLEVEL being a string instead of an int...
To get around the problem on can use a preprocessor trick. Define
#define _QM( x ) #x
#define QM( x ) _QM( x )
#define FL2STRING( x ) ( *QM( x ) == '"' ? ( const char * ) x : QM( x ) )
and you can print the FIXLEVEL always as a string with
printf( "%s\n", FL2STRING( FIXLEVEL ) );
even if FIXLEVEL was defined as an int.
Here's a short program that demonstrates that it works (and
the compilation doesn't emit any warnings, at least under gcc
with the warning level set to a rather sensitive value):
---------8<-----------------------------------
#include <stdio.h>
#define OLD 90
#define NEW "92sp2"
#define _QM( x ) #x
#define QM( x ) _QM( x )
#define FL2STRING( x ) ( *QM( x ) == '"' ? ( const char * ) x : QM( x ) )
int main( void )
{
printf( "%s\n", FL2STRING( OLD ) );
printf( "%s\n", FL2STRING( NEW ) );
return 0;
}
---------8<-----------------------------------
Sorry for the extra work I created for you! I wish you nice holidays
and a happy new year.
Best regards, Jens
--
\ Jens Thoms Toerring ________ address@hidden
\_______________________________ http://toerring.de