swick@ATHENA.MIT.EDU (Ralph R. Swick) (04/28/88)
Bob's recommendation (XDisplayString) is, of course, the correct way to solve your problem, (see last line below), but the real bug in your test case was incorrectly typing the resource variable. String resources are always passed as pointers. The following mods make your example work: #include <X11/Intrinsic.h> #include <X11/StringDefs.h> char *display, *dspname; static XtResource resources[] = { { "display", "Display", XtRString, sizeof(char *), (Cardinal)&display, XtRString, NULL }, }; main(argc, argv) int argc; char **argv; { Widget top_shell = XtInitialize("top", "test", NULL, 0, &argc, argv ); if (argc != 1) printf("extra args\n"); XtGetApplicationResources(top_shell, (caddr_t) NULL, resources, XtNumber(resources), NULL, 0); if (display != NULL) printf("display=%s\n", display); if ((dspname = XDisplayName(NULL)) != NULL) printf("dspname=%s\n", dspname); printf("Display=%s\n", XDisplayString(XtDisplay(top_shell))); }