Sunday, January 25, 2009

Windows Mobile madness

Windows Mobile madness

While some programming (yeah I do that) I came across this crazy weird thing happening causing a prefetch abort in execution.

For those who know the time_t datatype in C, it's defined in Windows Mobile in the most ambiguous way: In crtdefs.h as a 64 bit value and in stdlib.h in the Windows Mobile SDK (5 and 6) as an unsigned long (32 bits).

Visual Studio picks up the SDK definition at compile-time and link-time, BUT execution picks the crtdefs value if you have included crtdefs.h in your program before stdlib.h: EFFECT: Crash at runtime - try assigning a 64-bit type that's interpreted as a 32-bit one ... ARGH!

Took me a day and a tech-guru friend to walk through this to realize what was happening!

Gist: Include stdlib.h before crtdefs.h in case you are using time_t data-type in Windows Mobile Programming.

1 comment:

  1. sahi hai..i hv completely lost C touch :(

    ReplyDelete