Forte C compiler, SIZEOF from X11/xdm.h and macro concatenation

Hi,

I'm trying to trace the version of compiler I need to build some legacy software. The software can't be changed. I'm currently using:-

% cc -V

cc: Sun WorkShop 6 update 2 C 5.3 2001/05/15

with a demo licence.

I'm currently having problems compiling some code which makes use of the SIZEOF macro from /usr/openwin/include/X11/xdm.h. This macro uses concatenation to prefix the argument with 'sz_'. The problem I'm seeing is that 'sz_' is undefined at compile time; looking at the output of the preprocessor I see that a space has been added between the prefix and the argument (e.g. SIZEOF(x) produces 'sz_ x').

Questions:

1. Does this indicate an error in the way I'm using the compiler? I presume that the macro is defined as sz_/**/x, the null comment being replaced by a space. This definition is used because of #ifdef's in the xdm.h file guarding against using sz_##x. Is a -D flag required somewhere to force the correct definition?

2. I also don't want to change the make files in use if possible, so using a -D option is not ideal. Is there a later compiler version where any problem has been corrected?

Cheers,

Chris.

[1213 byte] By [Chris.Shawa] at [2007-11-26 14:51:02]
# 1
this style of code is for the pre-ansi preprocessor. Look at the -Xs option of cc.
Marc_Glissea at 2007-7-8 8:39:10 > top of Java-index,Development Tools,Solaris and Linux Development Tools...
# 2
The compiler you are using is End Of Life, and little support is available for it.I suggest you get the current compiler suite, Sun Studio 11, which is free. You can get it here: http://developers.sun.com/sunstudio/
clamage45a at 2007-7-8 8:39:10 > top of Java-index,Development Tools,Solaris and Linux Development Tools...
# 3

OK, the -Xs option forces it to work, but this is a change to the makefile.

I'm confused because this is 3rd-party software, using a standard macro from openwin.

The relevant code in the include file /usr/openwin/include/X11/Xmd.h is:

#if ((__STDC__ || defined(__cplusplus) || defined(c_plusplus)) && !defined(UNIXCPP)) || defined(ANSICPP)

#define _SIZEOF(x) sz_##x

#define SIZEOF(x) _SIZEOF(x)

#else

#define SIZEOF(x) sz_/**/x

#endif /* if ANSI C compiler else not */

Surely all the condition macros should be defined by the compiler/preprocessor - if there's an error in picking up the correct SIZEOF definition, it's because the wrong macros are defined? I believe that __STDC__ is defined as 0, which is why the evaluation falls through to the second clause.

Is the preprocessor at fault, and if so when was it fixed?

Chris.Shawa at 2007-7-8 8:39:10 > top of Java-index,Development Tools,Solaris and Linux Development Tools...
# 4
It is the header file that is at fault. __STDC__ was later replaced by defined(__STDC__).
Marc_Glissea at 2007-7-8 8:39:10 > top of Java-index,Development Tools,Solaris and Linux Development Tools...