Thanks for your answer. I understand what the warning means now, (I was
suspecting something like that already), but what I still don't understand
is why I get the warning in the first place.

When you look at the code below, you will see that I call DateToAscii with
two Byte values as the first parameters. This is exactly what the prototype
is asking for, so as far as I know, no casting takes place.
Therefore, I would think that a warning that I am casting incorrectly (or
better said: dangerously) is the last thing that should come here.



Date: 22 Nov 1999 13:11:37 -0800
From: Michael Pearce <[EMAIL PROTECTED]>
Subject: Re: Palm Dev Forum Digest 11/21/99

> prog.c:441: warning: passing arg 1 of `DateToAscii' with different width
due
> to prototype
> prog.c:441: warning: passing arg 2 of `DateToAscii' with different width
due
> to prototype

       -Wcast-align
              Warn  whenever  a pointer is cast such that the re-
              quired alignment of the target is  increased.   For
              example,  warn  if  a char * is cast to an int * on
              machines where integers can  only  be  accessed  at
              two- or four-byte boundaries.

The calling convention on most 16 and 32 bit platforms places arguments on
the stack in larger than 8 bit increments.  Byte is an 8-bit value, so when
you pass one, the rest of the 16 or 32 bits are unused.

This warning is nothing to worry about.  If you don't want to see it, don't
ask for it (by putting -Wcast-align on your command line).

- -- 
Michael Pearce <[EMAIL PROTECTED]>                           +1 314 386
0663
Coreth Consulting, Inc.                              St. Louis, Missouri,
USA



Was the answer on the following mail:




In general, I am pretty religious about writing software without any
warnings.
However, I recently wrote the following code:


#include <System\SysAll.h>
#include <UI\UIAll.h>

<snip>

static void PseudoFind2(FindParamsPtr params)
{
   char dateString[longDateStrLength];
   SystemPreferencesType prefs;
   Byte month;
   Byte day;
   Word year;
   month = 1;
   day = 1;
   year = 1999;
   DateToAscii(month, day, year, prefs.longDateFormat, dateString);
   <snip>
}

and got the following errors with GCC (cmmand line as follows):
m68k-palmos-coff-gcc -O1 -c -mdebug-labels -Wall -Wshadow -Wpointer-arith
-Wcast-qual -Wcast-align -Wwrite-strings -Wconversion -Waggregate-return
-Wstrict-prototypes prog.c -o prog.o


prog.c:441: warning: passing arg 1 of `DateToAscii' with different width due
to prototype
prog.c:441: warning: passing arg 2 of `DateToAscii' with different width due
to prototype

line 441 is the call to DateToAscii.

Has anybody an idea why I get these warnings ? I take care that I am passing
vairables of the same type as the documentation and the prototypes request.
I am using the headers of OS V3.1, where DateToAscii is defined as 

void DateToAscii(Byte months, Byte days, Word years, DateFormatType
dateFormat, CharPtr pString)
                        SYS_TRAP(sysTrapDateToAscii);


In fact, I got a whole bunch of extra warnings coming out of the header
files: They are all related to functions which are defined as non-void, but
are declared with a SYS_TRAP. The typical warning is: 

C:\PROGRA~1\PALMDE~1\lib\gcc-lib\m68k-palmos-coff/2.7.2.2-kgpd-071097/includ
e/Pa
lmOS/System/TextMgr.h: In function `TxtTransliterate':
C:\PROGRA~1\PALMDE~1\lib\gcc-lib\m68k-palmos-coff/2.7.2.2-kgpd-071097/includ
e/Pa
lmOS/System/TextMgr.h:274: warning: control reaches end of non-void function

Can anyone tell me if there is a way to get rid of these warnings without
getting rid of the checking in the non-SDK files (e.g. by adding some kind
of #pragma).

Thanks


Vriendelijke Groeten, Kind Regards, 
Mit freundlichem Gruss, Amiti�s
Jan Vereecke 

Reply via email to