Thread View: gnu.g++
1 messages
1 total messages
Started by Gilligan
Tue, 27 Feb 1990 23:03
The Xaw String typdef
Author: Gilligan
Date: Tue, 27 Feb 1990 23:03
Date: Tue, 27 Feb 1990 23:03
74 lines
3088 bytes
3088 bytes
Amazingly enough, I just ran into this problem yesterday. The main problem is that the X toolkit wants to define a String and c++ already has one. To avoid name conflicts they have a rather hideous #ifdef near the top of Intrinxic.h #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 makes every occurrence of String be replaced by char*, including #define XtNumber(arr) ((Cardinal) (sizeof(arr) / sizeof(arr[0]))) typedef char *String; // right here typedef struct _WidgetRec *Widget; typedef Widget *WidgetList; the String in the typedef. If you ran your program through the preprocessor you would discover that it was turning into typedef char *char*; -- My solution I just put these lines in my Makefile and used #include "X11/Intrinsic.h". X11/%.h : /usr/include/X11/%.h sed 's/\([^a-zA-Z"]\)String/\1XtString/g' < /usr/include/$@ | sed '/define XtString/ d' > $@ X11/Xaw/%.h : /usr/include/X11/Xaw/%.h sed 's/\([^a-zA-Z"]\)String/\1XtString/g' < /usr/include/$@ > $@ *************************** Warning! *************************** this requires you to now put every included X file in your dependency list for the .o files and create subdirectories X11 and X11/Xaw in your make directory. The sed scripts basically replace every ocurrence of String that needs replacing with XtString. There are quite a few instances where this would be VERY BAD! and thus the regex from hell. It is a nasty hack and the proper solution is to have everyone change to XtString (like my sedded header files:) instead of String. Another hack which would preclude use of the c++ String class, but fix the X include so it is sort of rational, is to put #ifndef String typedef char *String; #endif /*String*/ typedef struct _WidgetRec *Widget; around the lines in Intrinsic.h This is my rather nasty hack, but it has worked fine (i did run into problems at the start but that's what the \([a-zA-Z"]\) is for). If anyone has a better/cleaner/more obscure hack that would impress the heck out of me, POST it. I don't like my solution and would welcome a "better" one. To X hackers in particular, I have been having trouble using an app-defaults file. I can't figure out the application name I should prepend to resources to get it to work properly (yes, this belongs in comp.windows.X but I can't read its volume, period). THOTH out -=O=- -- ( My name's not really Gilligan, It's Robert Forsman, without an `e' )
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads