On Sat, Aug 02, 2003 at 09:26:39PM -0400, meg wrote:

> //database constants
> #define dbType (UInt32) "data"
> #define dbCreator (UInt32) "mws7"

These should be:

  #define dbType 'data'
  #define dbCreator 'mws7'

There is a HUGE difference between "data" (in double quotes) and 'data'
(in single quotes). 

The first is a string literal, which is a pointer, usually to somewhere
in the text section. It does not have a predictable value.

The second is an integer literal that uses a somewhat obscure feature of
C that lets you use multiple characters if the width of the variable is
wider than 1 byte.

For example, the following code is all valid C/C++:

 Char   a = 'a';      // Assign 0x61 
 UInt16 b = 'ab';     // Assign 0x6162 
 UInt32 c = 'abcd';   // Assign 0x61626364

The following will compile in C, but it is very unlikely what a
programmer wants:

 UInt32 x = "abcd";   // Assign something to x; the value is compiler dependent.

In C++ this won't even compile without a cast, and EVERY time you need
to cast anything that isn't a pointer, you should be doing some serious
introspection as to whether your code is correct.

-- 
Dave Carrigan
Seattle, WA, USA
[EMAIL PROTECTED] | http://www.rudedog.org/ | ICQ:161669680
UNIX-Apache-Perl-Linux-Firewalls-LDAP-C-C++-DNS-PalmOS-PostgreSQL-MySQL

-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/support/forums/

Reply via email to