Xref: utzoo comp.lang.c++:11783 comp.windows.x:33080 Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!tcs!nujoizey!gwu From: gwu@nujoizey.tcs.com (George Wu) Newsgroups: comp.lang.c++,comp.windows.x Subject: Re: Using C++ and X together (Problems) Keywords: C++ X header files function prototypes Message-ID: <1801@tcs.tcs.com> Date: 20 Feb 91 00:57:55 GMT References: <1991Feb19.153737.11179@msuinfo.cl.msu.edu> Sender: root@tcs.com Reply-To: gwu@nujoizey.tcs.com (George Wu) Followup-To: comp.lang.c++ Organization: Teknekron Communications Systems Lines: 26 Cc: bourd@buster.cps.msu.edu In article <1991Feb19.153737.11179@msuinfo.cl.msu.edu>, bourd@buster.cps.msu.edu (Robert Bourdeau) writes: |> Is anyone aware of problems using the X Toolkit and Xw with g++? |> |> I have been trying to compile a C++ program which incorporates X window |> stuff. I can't get past the compilation. Everything compiles fine until |> I add the X interface. When the X stuff was added, I started getting things |> like type conflicts, and even parse errors in the X header files. I presume you are using X11, Release 3. You problem arises because you are calling C functions from C++. You need to envelop all #include statements of X header files within an extern "C" statement. This will solve the prototype errors. Note this works only for g++, not other C++ compilers, because g++ does not check function prototypes within an extern "C" statement. There are a few places where the C++ keyword "class" is used in the X header files. This error can be corrected by using another name for the class field. George ---- George J Wu, Software Engineer | gwu@tcs.com or uunet!tcs!gwu Teknekron Communications Systems, Inc.| (415) 649-3752 2121 Allston Way, Berkeley, CA, 94704 | Quit reading news. Get back to work.