pwebb@yoyodyne.ncsa.uiuc.edu (Peter Webb) (02/10/91)
I'm having trouble getting a g++ program that uses Motif/X to compile. I've
localized the problem as follows:
In <X11/Intrinsics.h> there is the following code fragment:
#if defined(__cplusplus) || defined(c_plusplus)
#define CONST const
/* make const String do the right thing */
#define String char*
#else
#define CONST
#endif /* __cplusplus */
This is followed (at some distance) by the following line:
typedef char *String;
So, when __cplusplus or c_plusplus is defined, the compiler tries to parse
typedef char *char *;
which is clearly non-sensical.
I have installed patches to the X code up to number 18, the latest I saw on
expo.lcs.mit.edu. Are there later patches? Is this a known problem? Are
there other fixes for compiling with g++?
FYI, I am using g++ 1.37.1, Motif 1.1, X11R4 - patch level 18, on a Sun3
running SunOS4.
The error can be reproduced with the following code:
#include <stream.h>
#include <X11/Intrinsic.h>
main()
{
Widget x;
cout << "Party on!\n";
}
I use the following compile line:
g++ -I/stg2/GNU/lib/gcc-include -D__cplusplus -Dc_plusplus -sun3 -o test2 test2.c
And get this error:
In file included from //usr/include/sys/file.h:39, from /stg2/GNU/lib/g++-include/sys/file.h:18, from /usr/include/X11/Xos.h:81, from /usr/include/X11/Intrinsic.h:36, from test2.c:2:
/usr/include/sys/fcntlcom.h:62: warning: `flock' was declared `extern' and later `static'
In file included from test2.c:2:
/usr/include/X11/Intrinsic.h:102: parse error before `char'
Peter Webb (pwebb@ncsa.uiuc.edu)