melling@cs.psu.edu (Michael D Mellinger) (02/27/90)
Has anyone experienced this problem when using g++ and X11R4?
In the header file Intrinsic.h, a type String is declared. Whenever I compile
xmenu1.cc (an R4 example program) I get a parse error at line 102. I think
there might be a conflict with the String class in libg++. But I don't
include any libg++ header files!
Intrinsic.h
------------
#define XtNumber(arr) ((Cardinal) (sizeof(arr) / sizeof(arr[0])))
typedef char *String; <============= line 102
typedef struct _WidgetRec *Widget;
typedef Widget *WidgetList;
// Program begins here
// A simple Simple Menu Widget example.
// xmenu1.c -- From the X11R4 examples directory
// Copyright removed because I got tired of looking at it
#include <stdio.h>
#include "Intrinsic.h"
#include <X11/StringDefs.h>
#include <X11/Xaw/MenuButton.h>
#include <X11/Xaw/SimpleMenu.h>
#include <X11/Xaw/Sme.h>
#include <X11/Xaw/SmeBSB.h>
#include <X11/Xaw/Cardinals.h>
#define streq(a, b) ( strcmp((a), (b)) == 0 )
static void MenuSelect(), Syntax();
String fallback_resources[] = {
#ifdef COLOR_DISPLAY
/* For Color workstations. */
"*menu.menuLabel.foreground: Blue",
"*menu*quit.foreground: Green",
"*menu*item1.foreground: Red",
"xmenu1*menu*item2.foreground: White",
"*menu*item3.foreground: Blue",
"*menu*item4.foreground: Red",
#endif /* COLOR_DISPLAY */
"*menuButton.label: Click here for a pulldown menu",
"*menu.label: This is xmenu1",
"*menuLabel.vertSpace: 100",
"*blank.height: 20",
NULL,
};
void main(int argc, char** argv)
{
Widget top, command, menu, entry;
XtAppContext app_con;
int i;
static char * menu_item_names[] = {
"quit", "item1", "item2", "item3", "item4",
};
top = XtAppInitialize(&app_con, "Xmenu1", NULL, ZERO,
&argc, argv, fallback_resources, NULL, ZERO);
if (argc != 1)
Syntax(app_con, argv[0]);
command = XtCreateManagedWidget("menuButton", menuButtonWidgetClass, top,
NULL, ZERO);
menu = XtCreatePopupShell("menu", simpleMenuWidgetClass, command,
NULL, ZERO);
for (i = 0; i < (int) XtNumber(menu_item_names) ; i++) {
char * item = menu_item_names[i];
entry = XtCreateManagedWidget(item, smeBSBObjectClass, menu,
NULL, ZERO);
XtAddCallback(entry, XtNcallback, MenuSelect, NULL);
/*
* Create an extra blank entry after the third menu entry.
*/
if (i == 2)
entry = XtCreateWidget("blank", smeObjectClass, menu, NULL, ZERO);
}
XtRealizeWidget(top);
XtAppMainLoop(app_con);
}
/* Function Name: MenuSelect
* Description: called whenever a menu item is selected.
* Arguments: w - the menu item that was selected.
* junk, garbage - *** unused ***.
* Returns:
*/
/* ARGSUSED */
static void MenuSelect(Widget w, XtPointer junk, XtPointer garbage)
{
printf("Menu item `%s' has been selected.\n", XtName(w));
if (streq(XtName(w), "quit")) {
XtDestroyApplicationContext(XtWidgetToApplicationContext(w));
exit(0);
}
}
/* Function Name: Syntax
* Description: Prints a the calling syntax for this function to stdout.
* Arguments: app_con - the application context.
* call - the name of the application.
* Returns: none - exits tho.
*/
static void Syntax(Xt AppContext app_con, char* call)
{
XtDestroyApplicationContext(app_con);
fprintf( stderr, "Usage: %s [-label <label name>]\n", call);
exit(1);
}