Path: chuka.playstation.co.uk!news From: sosman@terratron.com (Steven Osman) Newsgroups: scea.yaroze.freetalk Subject: Re: Net Yaroze C++ Examples Date: Fri, 28 May 1999 22:25:00 GMT Organization: PlayStation Net Yaroze (SCEE) Lines: 134 Message-ID: <37521782.700423525@news.playstation.co.uk> References: <374c6512.1232873@news.scea.sony.com> <3750cfe3.682088281@news.playstation.co.uk> <3750f0e6.14195942@news.playstation.co.uk> NNTP-Posting-Host: 209.27.57.69 Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Newsreader: Forte Agent 1.5/32.452 On Fri, 28 May 1999 19:43:57 GMT, daniel@reichardt.ch (Daniel Hartmeier) wrote: >On Fri, 28 May 1999 17:19:10 GMT, sosman@terratron.com (Steven Osman) >wrote: > >> If you have CodeWarrior, you can find all the fixes necessary IN your >> codewarrior installation! Check in your codewarrior folder for a >> folder called "unsupported" > >Unfortunately, you still need to tweak the headers and startup code a >little. There is, for instance, a function called delete() in libps.h, >and delete is a reserved word under C++. Dennis Payne already mentioned >Chris Blackwell's page with further details. There is a readme file in that folder. Here is an excerpt from that file (it is called "C++Support Readme.txt") (begin excerpt) Modifying LIBPS.H to compile under C++ ----------------------------- There are several problems presented to people who wish to use the current Yaroze header in a C++ environment. It becomes somewhat obvious after cursory examination of LIBPS.H that the authors of the library have never used C++. Fortunately you can remedy this situation with a few minor fixes to the header. The problems I have run in to thus far are: 1.The functions are not typed as extern "C" 2.A function named "delete" exists in the header 3.Some of the function prototypes do not match their actual expected parameters I'd like to thank Nick Porcino for his suggestion on how to work around the problem with the delete() function. Problem #1 - The functions are not typed as extern "C" This is easily solved by adding this line just before the first function is declared. I put mine in just after the "prototypes" comment. #if defined(_LANGUAGE_C_PLUS_PLUS)||defined(__cplusplus)||defined(c_plusplus) extern "C" { #endif Now add this line at the end of the file, just before the comment "End on file." #if defined(_LANGUAGE_C_PLUS_PLUS)||defined(__cplusplus)||defined(c_plusplus) } #endif Problem #2 - A function named "delete" exists in the header This is a bit more difficult to deal with. Nicks suggestions is as follows: Step 1: Remove the line "extern int delete(char *);" from the header, as we'll be putting the line elsewhere in the file. Step 2: Add the following line into the file. I put mine at the very bottom of the function declarations so I didn't loose it. #if defined(_LANGUAGE_C_PLUS_PLUS)||defined(__cplusplus)||defined(c_plusplus) int deletefile(char* theFile); #else extern int delete(char *); #endif Step 3: Now you'll need to create a file with the following contents. I called mine "delete.c" #include int deletefile(char* theFile) { return delete(theFile); } Step 4: Add this file to whatever C++ project you are using. In Metrowerks, I have created a new stationary which creates a C++ Yaroze project and includes this file automatically. Be sure that if you are using this technique that C files are not getting compiled with a C++ compiler, otherwise this file will not compile. You can find a copy of this file here. Problem #3 - Some of the function prototypes do not match their actual expected parameters I have run into two of these functions which don't match their declarations, but there are still many functions I have not tried calling yet. If you find any more, please e-mail me so I can fix them in my header and add then into my list. Function: FntPrint() What it ships as: int FntPrint(); This is clearly wrong, since FntPrint takes a variable length parameter list. Strangely enough, the documentation lists the parameters as (int id, format, ...). This is strange because none of the sample code uses the first int parameter. In fact, I'm not even sure what streams are used for, or why you would want to use them. All of the sample code for printing fonts that I have seen, uses -1 wherever the stream id is requested (like in FntFlush.) Hmmm. Anyone with more information on font streams, please e-mail me. Sony? What it should be: int FntPrint(char* format,...) Actually, this doesn't always work. I don't know why. I'll post as soon as I do! Function: KanjiFntPrint() What is ships as: int KanjiFntPrint(); What it should be:int KanjiFntPrint(char* format,...); See FntPrint() above to see why.