I have Metrowerks CodeWarrior Lite for Palm and when I'm using offsetof() I
get error:
Error : function has no prototype
MemoPad.c line 1458 DmWrite(s, offsetof(PackedProduct, amount),
&product->amount, sizeof(product->amount));
Is that not a standard function, or should I include something to get this
to work?
I deeply appreciate your efforts to answer this question, thank you!
Kristo
Actually, it does with no problem. The only issue is adding the access path
to see the Metrowerks Standard Library. As long as you stick to the
freestanding subset of the library, MSL works great with PalmOS.
> Once upon a time, an engineer at Palm who only uses CodeWarrior added an
> offsetof() macro to PalmTypes.h. I told him that he'd have to work a bit
> harder to avoid conflicting with the macro provided by various compilers'
> stddef.h headers. Instead of working harder, he changed the
capitalisation.
> PalmTypes.h says OffsetOf not by design, but by accident.
Yow! ...all this time, I thought it had been a Blessed creation, along with
MemSet and StrLen.
> I regret that I didn't take it upon myself to fix this before the 3.5 SDK
> left the building. Along with not campaigning harder for us to use the
> C99 standard's uint32_t instead of UInt32, etc, I consider this one of my
> greatest personal failures while I've been working on the SDK.
Using stdint.h would have rocked. Too bad; I guess a general rule for SDK
design is to look at the practices of Microsoft and the Win32 SDK and do the
opposite. At least WORD and DWORD are gone.
--
Ben Combee
Veriprise Wireless <http://www.veriprise.com>
offsetof is not Palm standard. The PalmOS headers supply the replacement
called "OffsetOf". Notice the capitalization.
It never ceases to amaze me that people can say this with a straight face.
I've been programming in C for over ten years. Why would I want to use
OffsetOf on one particular system when offsetof is what I've been using
everywhere else all that time? Should I spell sizeof as SizeOf if Palm
were to tell me to?
With m68k-palmos-gcc you can write
#include <PalmOS.h>
#include <stddef.h>
... code using offsetof() ...
just as you would expect. Just because PalmTypes.h pollutes your
namespace with OffsetOf() doesn't mean you have to use it.
If CodeWarrior for Palm OS won't let you #include <stddef.h> like that
then it's not even a conforming freestanding implementation of Standard C.
If that's the case, it's pathetic.
Once upon a time, an engineer at Palm who only uses CodeWarrior added an
offsetof() macro to PalmTypes.h. I told him that he'd have to work a bit
harder to avoid conflicting with the macro provided by various compilers'
stddef.h headers. Instead of working harder, he changed the capitalisation.
PalmTypes.h says OffsetOf not by design, but by accident.
I regret that I didn't take it upon myself to fix this before the 3.5 SDK
left the building. Along with not campaigning harder for us to use the
C99 standard's uint32_t instead of UInt32, etc, I consider this one of my
greatest personal failures while I've been working on the SDK.
John "pedantic standards freak"
Judging by number of times this comes up, I consider that too much of an
impediment. :-)
> Yow! ...all this time, I thought it had been a Blessed creation, along with
> MemSet and StrLen.
It's funny you should mentioned the &*#@&! blessedness of MemSet!
John
Well, that would be most people. It's not like anyone here is a fan of it
either. MemSet was implemented when there were just a few people working
for Palm. There wasn't a whole lot of opportunity for peer review and
feedback. The guy who did MemSet just got it wrong. And once it got
shipped that way, it had to stay that way.
-- Keith Rollin
-- Palm OS Emulator engineer
CW Lite does not include MSL -- it was stripped out of the distribution
along with other parts in order to make the download as light as possible.
> offsetof is not Palm standard. The PalmOS headers supply the replacement
> called "OffsetOf". Notice the capitalization.
I get the very same error msg that the function has no prototype even with
OffsetOf. Pilot.h is included.
Maybe they have shipped some weird old version of SDK with MW Palm Lite,
which btw does not include MW help and reference files at all...
Kristo
You have no idea how happy I am to know that there are people in Palm's
development group who regret MemSet(). :)
--
= Warren Young -- Maintainer of the Palm OS Programmer's FAQ at:
= http://www.cyberport.com/~tangent/palm/faq/
=
= ICBM Address: 36.8274040 N, 108.0204086 W, alt. 1714m
This might be a RTFM, but could you advise where I can find MSL? Could it be
Lite ships with the 3.1 SDK (which was current at the time that Lite was
completed). OffsetOf is defined in the 3.5 SDK. Since the 3.5 SDK is not
available for the Lite version, you will need to get the full product to use
this macro.
-hkmlt