Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!ncar!gatech!bloom-beacon!dont-send-mail-to-path-lines From: don@zardoz.coral.COM (Don Dewar) Newsgroups: comp.windows.x Subject: Can I build X application with g++? Message-ID: <9103291938.AA02957@zardoz.coral.com> Date: 29 Mar 91 19:38:05 GMT References: <1991Mar29.062737.1803@chpc.utexas.edu> Sender: tytso@athena.mit.edu (Theodore Y. Ts'o) Organization: The Internet Lines: 77 ) Return-Path: ) Date: 29 Mar 91 06:27:37 GMT ) From: uunet!chpc.utexas.edu!xxvb746 (Yanling Qi (UT CHPC)) ) Organization: The University of Texas System - CHPC ) Subject: Can I build X application with g++? ) Newsgroups: comp.windows.x ) References: <1991Feb28.010627.895@lta.com> ) Sender: uunet!expo.lcs.mit.edu!xpert-request ) To: xpert@expo.lcs.mit.edu ) ) Hello friend, ) ) I have a project needed to be implemented in X with g++. I do not know ) if one can build X application with g++. I copyed the "puzzle source code" ) from the subdirectory X11 from my system to my directory and got my makefile ) by using "cmkmf". I compiled them successfully then I modified the makefile ) by changing CC = gcc ( original is CC = cc) and recompiled them successfully ) too. I got hundreds error when I changed CC =g++ and recompiled the codes. ) ) My questions were: ) (1) Can one biuld X application with g++? Yes, you can build X applications with g++. The problem you ran into is a problem with C++ in general. ) (2) if((#1) == yes) how should I deal with my c functions? As you may already know, most C++ compilers use a name munging scheme to differentiated overloaded functions. What you have to do when calling "C" functions is tell the C++ compiler not to do that. So you must declare the function using the following syntax. extern "C" { void cfunction1(char *, int); void cfunction2(char *, int); }; or extern "C" void cfunction1(char *, int); The function name, arguments and return value are at the programmers discretion of course. This syntax is know as the linkage section or linkage specfication. There is reference to it in the cfront 2.0 language spec and the C++ Annotated Reference Manual. I hope this is the problem you were referring to. I believe that ULowell has a set of X includes that are C++ compatible. What we usually do when we include X headers is this. extern "C" { #include } ) ) Thank you! ) ) ) ----yanling ) ) +---------+ | Coral | |@@@@@*@**| |@@*@@**@@| Don Dewar |*@@**@@@@| Coral Network Corporation, Marlborough, MA |@***@@@@@| Internet: don@coral.com |@@**@@@@@| Phone: (508) 460-6010 |*********| Fax: (508) 481-6258 |Networks | +---------+