Try this:

/*********************************************************************
 * Global variables
 *********************************************************************/
typedef struct {
char FirstName[20];
char LastName[20];
char PhoneNum[20];
} TransStruct;
typedef TransStruct TransStructType;
typedef TransStruct* TransStructPtr;

DmOpenRef gTransformer;

Err OpenOrCreateDB(DmOpenRef *dbP, UInt32 type, UInt32 creator, UInt16 mode,
UInt16 cardNo, char* name, Boolean* created);

static Err AppStart(void)
{
UInt16 mode = dmModeReadWrite;
Err err = errNone;
TransStruct *c;
Boolean created;
Char* DBName = (Char*) MemPtrNew(15);  // allocate 15 bytes
DBName = "Transformers";

//Find the Transformer Database.  If it doesn't exist, create it.

OpenOrCreateDB(&gTransformer, 'DATA', '!!$g', mode, 0, DBName, &created);

return err;
}


//NEW CODE!!!
//Open a database.  If it doesn't exist, create it.

Err OpenOrCreateDB(DmOpenRef *dbP, UInt32 type, UInt32 creator, UInt16 mode,
UInt16 cardNo, char* name, Boolean* created)
{
Err err = errNone;
*created = false;
*dbP = DmOpenDatabaseByTypeCreator(type, creator, mode);
if (!*dbP)
{
err = DmGetLastErr();
if (err==dmErrCantFind)
err = DmCreateDatabase(cardNo, name, creator, type, false);
if (err != errNone)
return err;
*created = true;
*dbP = DmOpenDatabaseByTypeCreator(type, creator, mode);
if (! *dbP)
return DmGetLastErr();
}
return err;
}


What is happing is that you are using OpenOrCreateDB before it is actually
being defined and the compiler doesn't know what it will return or its
parameters, so it assumes that they are "int" by default. Once you define
the function and it does not return as "int" the compiler complains.

I would actually put "extern Err OpenOrCreateDB(DmOpenRef *dbP, UInt32 type,
UInt32 creator, UInt16 mode, UInt16 cardNo, char* name, Boolean* created);"
in a header file included at the top of the source file that uses that
function.

-Donald

"Del Ventruella" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> I am trying to call a function.  It is passing a number of variables
relevant to calling a database.  I define the function, per a text I have.
I call the function.  CodeWarrior informs me:
>
> Error   : identifier 'OpenOrCreateDB(...)' redeclared
> was declared as: 'int (...)'
> now declared as: 'unsigned short (void **, unsigned long, unsigned long,
unsigned short, unsigned short, char *, unsigned char *)'
>
>
> THE CALLING FUNCTION FOLLOWS (THE CALL IS MADE ONE LINE UP FROM LAST CODE
LINE):
>
>
>
> static Err AppStart(void)
> {
> UInt16 mode = dmModeReadWrite;
> Err err = errNone;
> TransStruct *c;
> Boolean created;
> Char* DBName = (Char*) MemPtrNew(15);  // allocate 15 bytes
> DBName = "Transformers";
>
> //Find the Transformer Database.  If it doesn't exist, create it.
>
> OpenOrCreateDB(&gTransformer, 'DATA', '!!$g', mode, 0, DBName, &created);
>
> return err;
> }
>
>
> THE FUNCTION THAT IS CALLED IS:
>
>
>
> //NEW CODE!!!
> //Open a database.  If it doesn't exist, create it.
>
> Err OpenOrCreateDB(DmOpenRef *dbP, UInt32 type, UInt32 creator, UInt16
mode, UInt16 cardNo, char* name, Boolean* created)
> {
> Err err = errNone;
> *created = false;
> *dbP = DmOpenDatabaseByTypeCreator(type, creator, mode);
> if (!*dbP)
> {
> err = DmGetLastErr();
> if (err==dmErrCantFind)
> err = DmCreateDatabase(cardNo, name, creator, type, false);
> if (err != errNone)
> return err;
> *created = true;
> *dbP = DmOpenDatabaseByTypeCreator(type, creator, mode);
> if (! *dbP)
> return DmGetLastErr();
> }
> return err;
> }
>
>
> Have any data types or representations of data types that were legal a few
years ago when the code from which I am borrowing was written ceased to be
allowed?  There are a series of additional messages after the error that
begins this post asserting that variable names are not defined.
>
> undefined identifier 'created'
> undefined identifier 'dbP'
> undefined identifier 'cardNo'
>
> I create the following as global variables:
>
> /*********************************************************************
>  * Global variables
>  *********************************************************************/
> typedef struct {
> char FirstName[20];
> char LastName[20];
> char PhoneNum[20];
> } TransStruct;
> typedef TransStruct TransStructType;
> typedef TransStruct* TransStructPtr;
>
> DmOpenRef gTransformer;
>
>
> ANYONE WHO CAN CLEAR THE BASIS FOR THIS ERROR SEQUENCE UP FOR ME WOULD BE
PROVIDING A GREAT FAVOR.  I HAVE PROBABLY FAILED TO PROPERLY DEFINE A
VARIABLE TYPE, BUT SIMPLY DON'T SEE WHERE.
> THANK YOU.
>



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

Reply via email to