PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

can't use STL in Codewarrior

I want to use STL strings in Codewarrior for Palm OS with GapiDraw, but I can't get my project to compile. To make sure nothing in my project was causing the problem, I opened up simple.mcp from the palm samples and added this line to myapplication.cpp.
#include <string>

Below are the errors I got when I tried to compile. I'm using GapiDraw 3.5 Beta 3. If I create a project that doesn't use GapiDraw in Codewarrior, I can use std::string without any problems.



Error : macro 'stdin' redefined
(included from:
cstdio:26
string:354
myapplication.cpp:5)
file_struc.h line 185 (&__std(__files[0])) /*- mm 961031 -*/ /*- mm 961203 -*/ /*- mm 000201 -*/

Error : macro 'stdout' redefined
(included from:
cstdio:26
string:354
myapplication.cpp:5)
file_struc.h line 186 (&__std(__files[1])) /*- mm 961031 -*/ /*- mm 961203 -*/ /*- mm 000201 -*/

Error : macro 'stderr' redefined
(included from:
cstdio:26
string:354
myapplication.cpp:5)
file_struc.h line 187 (&__std(__files[2])) /*- mm 961031 -*/ /*- mm 961203 -*/ /*- mm 000201 -*/

Error : declaration syntax error
(included from:
string:354
myapplication.cpp:5)
cstdio line 57 StrVPrintF(char * s,(const Char *)const char * format,va_list arg)

Error : illegal use of 'inline'
(included from:
string:354
myapplication.cpp:5)
cstdio line 124 Siofgetc( (& ::std::__files[0]))

Error : data type is incomplete
(included from:
string:354
myapplication.cpp:5)
cstdio line 125 { return getc(stdin); }

Error : declaration syntax error
(included from:
string:354
myapplication.cpp:5)
cstdio line 127 Siofputc(int c, (& ::std::__files[1]))

Error : expression syntax error
(included from:
string:354
myapplication.cpp:5)
cstdio line 131 { return file->state.eof; }

Error : expression syntax error
(included from:
string:354
myapplication.cpp:5)
cstdio line 134 { return file->state.error; }

Error : declaration syntax error
(included from:
string:354
myapplication.cpp:5)
cstdio line 170 }
GapiDraw 3.5 beta3 contained the old Palm code and had some issues. Please download the latest RC1 - most of the Palm native code has been completely rewritten.
Ok, it compiles now when I add #include <string> to the minimal example for Palm OS 5, but when I add these lines in ProcessNextFrame,


std::string my_string;
my_string = "My String";


I get this error in the emulator when I launch the program. I'm using the Palm Tungsten C Simulator.
I:\Ripple\ARM\Core\Emul68K\Src\Error68K.c, Line:1543, Write to WindowType (id 65535) off: 20, size: 4


By the way, no message comes up on the splash screen anymore. It's just an empty box.
To fix the error, you need to replace the following lines in "include/palm-os5/GapiDrawDefines.h"

Code:

#define memcpy(destP, sourceP, numBytes) MemMove(destP, sourceP, numBytes)
#define memset(destP, value, numBytes) MemSet(destP, numBytes, value)
#define free MemPtrFree


with this code

Code:

inline void * memcpy (void * dst, const void * src, size_t len)
{ MemMove(dst, src, (Int32)len); return dst; }
inline void * memset(void * dst, int ch, size_t len)
{ MemSet(dst, (Int32)len, (UInt8)ch); return dst; }
inline void free(void *ptr)
{ if (ptr) { MemPtrFree(ptr); } }



By the way, no message comes up on the splash screen anymore. It's just an empty box.


This occures because you did not copy the file "include/palm-os5/simulator/gdarm.dll" to your simulator folder.
Thanks! That worked!
Ok, ran into a problem with the changes you suggested. I tested this with my project as well as all the samples for Palm OS 5 and I get the same error everytime. Everything runs fine, but when I exit the program I get this error.
MemoryMgr.c, Line:3675, Invalid chunk ptr

By the way, I'm testing this out on the Tungsten C Simulator.