bartop

palmoswerks ARCHIVE
Palm OS programming tips from a (former) CodeWarrior insider

header

Navigation

Search
Home
About
Stories
Stuff I Like
Articles
PilRC
CodeWarrior
palmos.techwood.org
DevTools List
Palm OS Dev FAQ

The Secret of InitCode

If you ever build a Palm OS program and get an linker error message about "__InitCode__", you'd be right to be confused, since you don't actually have a function called that in your program. This is one of the "undocumented" parts of CodeWarrior that really should be explained.

C++ lets you have global variables that are initialized at program launch time. Some of these might just be simple variables with expressions that can't be evaluated at compile time, while others might be complex instances of classes that have detailed constructor functions.

To perform these intializations, each source file which has variables of this type produces a special intialization function. This function just has code to set the values and call the constructors for all these variables. At link time, the linker just concatentates this code from all your source files into one big function that is placed in the first segment. The CodeWarrior runtime library has a dummy function called __InitCode__ that serves as a placeholder for the linker, giving it a stub onto which it can append the initialization code from all the other source files.

If you get an error about the linker not finding this function, it means you used this language feature, but you don't have the CW runtime library included in your project.

Really Fixed 8.2 Patch Online

As of last Wednesday, the 8.2 patch available from Metrowerks has the runtime library fix I first posted at this site. This patch is highly recommended for any V8 user. There are still a few minor bugs in the Palm OS tools that I want to fix for 8.3, but I feel really good about where it is right now.

brought to you by weblogger.com


Send feedback to combee@techwood.org
Copyright © 2004 Benjamin L. Combee
Palm OS is a registered trademark of PalmSource, Inc.
Metrowerks and CodeWarrior are registered trademarks of Metrowerks Inc.

The views expressed on this website/weblog are those of mine alone and do not necessarily reflect the views of PalmSource or Metrowerks.

This is a Manila Site

qwertYAK / frobnovich