Getting date values in C, on Windows

I have the following segment of code, where value is a REALobject representing a Date value.

[code] long year, month, day, hour, minute, second;
float gmtOffset;

assert(REALGetPropValue(value, "Year", &year));
assert(REALGetPropValue(value, "Month", &month));
assert(REALGetPropValue(value, "Day", &day));
assert(REALGetPropValue(value, "Hour", &hour));
assert(REALGetPropValue(value, "Minute", &minute));
assert(REALGetPropValue(value, "Second", &second));
assert(REALGetPropValue(value, "GMTOffset", &gmtOffset));

[/code]

This works just fine on OS X, but when I run on Windows, Year turns out being a large, random number and the rest of the values zero. I would assume I’m doing something wrong, but it works great on OS X.

Any thoughts?

OK, I worked on this some more this evening and realized that if I compile a debug version of my DLL on Windows, it works great. Compile a release version, it fails miserably, only on passing the date. So, I am assuming therefore, I have some optimization flag set that Xojo is not liking on the Windows/Release side of things. I’ll spend some more time with it tomorrow and hopefully report back success tomorrow and let you know which setting was causing this issue.

If you initialize the values to something specific (noticeably bogus), do they stay bogus? Also, have you tried running on OS X with Guard Malloc enabled? I’ve found it very helpful in rooting out bugs, even if they may appear platform specific.

If I initialize the values to something bogus, they stay at their bogus values. Does this give you any clue? I have some 200 functions in my plugin and the only two (that I have found) that do not work properly under Windows when compiled for Release mode are the only two that receive a date value from Xojo.

I have not tried OS X with guard malloc enabled, I will do that next.

Well, assert() may not work here. Maybe you write it in temp variables instead so you can output result?

Ah yes, it’s very possible for code inside of assert macros to get stripped out if NDEBUG is set.

Duh! That was indeed it, works like a champ now. Thanks again Christian!