Closed Looongcat closed 10 years ago
1) Look at me. Now look at your compiler. Now look at me. Now look at the calendar. It's 2014. C89 is 25 years old. Everything is possible when your IDE's default settings suck. I'm on a horse.
C99 is widely supported, and writing in that 1989 dialect is no fun at all. Here's how to set it under Code::Blocks:
2) Have you tried building with -Dtimegm=_mkgmtime
or -Dtimegm=mktime
?
1) But if you can write code which will work under any c compiler - why not?
2) Tried when you said, but it didn't help at all (dunno why). Nope, my fault. It really works.
ad 1) as stated in README.md: "Written in ISO C99". It's a project decision made at the beginning of development. Standard compliance it's not only a matter of "for" syntax but any other feature of C99 that is in use. Case closed.
P. S. Maybe it'll help to add in .h:
#ifdef __WIN__
#define timegm=mktime
#endif
or something similar :)
The problem with timegm
is that it's a GNU extension (that's also present on some other platforms besides Linux, notably OS X) and there's no single corresponding function on other platforms. Most systems have mktime
, but it only works correctly as long as you're running under UTC timezone; Windows has _mkgmtime but I have no idea how portable between different Windows implementations it is. Doing this correctly requires lots of cross-platform knowledge, which I unfortunately lack - so I left it as-is.
And yeah, as @swistakm said, using the modern C99 features is a design decision.
Well, case is really closed. Thank you guys.
- Look at me. Now look at your compiler. Now look at me. Now look at the calendar. It's 2014. C89 is 25 years old. Everything is possible when your IDE's default settings suck. I'm on a horse.
C99 is widely supported, and writing in that 1989 dialect is no fun at all. Here's how to set it under Code::Blocks:
- Have you tried building with
-Dtimegm=_mkgmtime
or-Dtimegm=mktime
?
Add Dtimegm=mktime
worked for STM32 platform compiled by ARMCLANG.
Hi guys! You're doing awesome project, but here's some small troubles i've got on windows platform with code::blocks & mingw (dunno what about stm32, but i think that iar will get the same troubles):
1) Loop variables was declared inside of loop header Such construct requests at least C99 mode. It's better to declare all necessary variables before function's code for compability with C89 so the code looks like:
2) Seems like timegm function isn't presented in windows libraries, so here it's code (which is obviously very bad for embedded because of multiplication):