At 10:04 AM -0700 5/13/99, Adam Dingle wrote: >Thanks to everyone who responded to my posting asking whether there was some >predefined preprocessor symbol indicating that CodeWarrior is building for >PalmOS. > >It turns out that the compiler itself does define __PALMOS_TRAPS__, >as Michael Yam suggested. This is basically what I was looking for, >although the name __PALMOS_TRAPS__ is unfortunate and is >unfortunately undocumented. The symbol EMULATION_LEVEL gets defined >in PalmOS header files, not by the compiler. > >A number of people suggested that I can use a prefix file in my >CodeWarrior project file to define a symbol indicating that we are >building for PalmOS, which is OK, but I was really looking for a way >to write a cross-platform source file which can be dropped into any >project. > >In conclusion, CodeWarrior SHOULD define a symbol such as >"__palmos__" or "palm" when building for PalmOS, and this should be >documented and supported behavior. Of course, virtually every other >C compiler defines a symbol indicating the target platform. I >suggest that CodeWarrior define the symbol "__palmos__"; that would >be convenient for programmers since GCC defines "__palmos__" when >compiling code for PalmOS. Would you expect this symbol to be defined when compiling Palm code into a Macintosh Simulator application? In that case, Metrowerks thinks it's generating Macintosh code, not Palm code. The Metrowerks 68K compiler is used to generate generic 68K code, not Macintosh code or Palm OS code. Generating Palm-specific code is a function of setting the 68K Target pref panel to "Palm OS Application" (or "Palm OS Code Resource"). However, it's still a 68K compiler, generating 68K code. The "__PALMOS_TRAPS__" define is used by the Palm header files to determine whether or not to use the TRAP instruction (via the TWOWORD_INLINE macro) to access Palm OS system APIs. This is the differentiator between compiling Palm OS code targeted for the device and compiling Palm OS code targeted for a simulator application. I wouldn't really expect to see a "__palmos__" define in the Metrowerks compiler, since I have no idea how they would do it (again, given that the same compiler is used to generate Macintosh Simulators and non-Palm Macintosh apps, as well as Palm applications). --Steve
