rune.johansen%odin.re.nta.uninett@NAC.NO (Rune Henning Johansen) (06/13/90)
In a C++-program I have this line: #include <X11/Intrinsic.h> How can I avoid: /usr/include/X11/Intrinsic.h:102: parse error before `char' or "/usr/include/X11/Intrinsic.h", line 102: error: syntax error: * char "/usr/include/X11/Intrinsic.h", line 102: error: syntax error -Rune.
pattersw@cs.rpi.edu (William Patterson) (07/20/90)
I recieved several replies to my first posting, but none that really
solved the problem (compiling X & athena widgets with g++). Most of
the responses started "Well, without more details I can't tell for
sure..."
So, in hopes that more details will aid some kind person in finding
where I'm going wrong, here are the details...
------------ The Compile Command --------------------
g++ junk.c \
-fwritable-strings -fstrength-reduce -felide-constructors \
-fschedule-insns -fdelayed-branch -fsave-memoized \
-lXaw -lXmu -lXt -lXext -lX11
Note : I get the same errors using -ansi or -traditional in place of
all the -f... flags (which I don't understand but which were
suggested by somone via e-mail)
---------------- Errors Porduced ---------------------
In file included from /usr/local/gnu/lib/g++-include/sys/time.h:3, from /usr/include/X11/Xos.h:121, from /usr/include/X11/Intrinsic.h:36, from junk.c:2:
/usr/local/gnu/lib/g++-include/time.h:60: warning: type declaration of timezone shadowed
In file included from junk.c:2:
/usr/include/X11/Intrinsic.h:102: parse error before `char'
junk.c:6: parse error before `fallback_resources'
junk.c:6: warning: initialization of integer from pointer lacks a cast
junk.c:6: warning: data definition lacks type or storage class
junk.c:12: `argc' undeclared, outside of functions
junk.c:12: `argv' undeclared, outside of functions
junk.c:13: parse error before `int'
junk.c:15: parse error before `{'
junk.c:20: conflicting types for `toplevel'
junk.c:21: warning: initialization of integer from pointer lacks a cast
junk.c:21: warning: data definition lacks type or storage class
junk.c:23: parse error before `void'
junk.c:25: warning: data definition lacks type or storage class
junk.c:26: warning: data definition lacks type or storage class
junk.c:27: parse error before `}'
Compilation finished at Fri Jul 20 00:10:00
--------------- The Program ---------------------
#include <stdio.h>
#include <X11/Intrinsic.h>
#include <X11/Xaw/Label.h>
#include <X11/Xaw/Cardinals.h>
String fallback_resources[] = { "*Label.Label: This is xlabel", NULL };
static XrmOptionDescRec options[] = {
{"-label", "*Label.label", XrmoptionSepArg, NULL}
};
main(argc, argv)
int argc;
char **argv;
{
static void Syntax();
XtAppContext app_con;
Widget toplevel;
toplevel = XtAppInitialize(&app_con, "Xlabel", options, XtNumber(options),
&argc, argv, fallback_resources, NULL, ZERO);
(void) XtCreateManagedWidget("label", labelWidgetClass, toplevel,
NULL, ZERO);
XtRealizeWidget(toplevel);
XtAppMainLoop(app_con);
}
-------------------- END -----------------------------
--
-----------------------------------
Bill Patterson
pattersw@turing.cs.rpi.edu
Computer Science Department
Rensselaer Polytechnic Institute
Troy, NY.
-----------------------------------swick@ATHENA.MIT.EDU (Ralph R. Swick) (07/20/90)
In file included from junk.c:2:
/usr/include/X11/Intrinsic.h:102: parse error before `char'
You need to install fixes 10 and 11 (and any preceeding ones
you may be missing).brock@SUMEX-AIM.STANFORD.EDU (Kevin Brock) (07/20/90)
The problem was with the program, not the compile-line. I've included the
modified version below; it will compile and run on a SPARC Station 1 running
Sun OS 4.0.3c using GNU's g++ and X11R4.
The compile line was:
g++ junk.c -lXaw -lXmu -lXt -lXext -lX11
You might want to think about either using the extern "C" {} declaration for
the X headers or making sure that they're all modified to be C++ compatible.
---------------------------- junk.c -------------------------------------
#include <stdio.h>
#include <X11/Intrinsic.h>
#include <X11/Xaw/Label.h>
#include <X11/Xaw/Cardinals.h>
String fallback_resources[] = { "*Label.Label: This is xlabel", NULL };
static XrmOptionDescRec options[] = {
{"-label", "*Label.label", XrmoptionSepArg, NULL}
};
main(int argc, char** argv)
{
static void Syntax();
XtAppContext app_con;
Widget toplevel;
toplevel = XtAppInitialize(&app_con, "Xlabel", options, XtNumber(options),
&argc, argv, fallback_resources, NULL, ZERO);
(void) XtCreateManagedWidget("label", labelWidgetClass, toplevel,
NULL, ZERO);
XtRealizeWidget(toplevel);
XtAppMainLoop(app_con);
}
---------------------------
Kevin Brock
brock@sumex-aim.stanford.edu
-------