Page MenuHomePhabricator

about localtime_r (unix and windows)
Closed, ResolvedPublic

Description

acording to this linux man page : https://linux.die.net/man/3/localtime_r one should include at least _POSIX_C_SOURCE

afaics, localtime_r is used only in elementary (git grep shows it is in tests, examples, lib and a module) and they include Elementary.h and Efl_UI.h

but what is interesting is that mingw-w64 also declares localtime_r if _POSIX_C_SOURCE is defined (i guess that they use localtimee_s which is declared since Vista. localtime_r and localtime_s have arguments in the reverse order). Currently, i define localtime_r in Evil using localtime_s. So that would reduce even more the size of Evil(ness) if we define _POSIX_C_SOURCE just before including time.h in Elementary.h and Efl_UI.h.

so do you think that there is a problem if we define _POSIX_C_SOURCE just before including time.h in Elementary.h and Efl_UI.h ?

vtorri created this task.May 3 2019, 11:39 PM
vtorri updated the task description. (Show Details)May 3 2019, 11:57 PM
vtorri added a comment.May 4 2019, 3:41 AM

Note that solaris man page also mentions that one should define _POSIX_C_SOURCE for re-entrant functions

vtorri added a comment.May 5 2019, 2:50 AM

to make it short, i would like to pass -D_POSIX_C_SOURCE to cflags for the whole project. If you think it's too much, we can pass -D_POSIX_C_SOURCE only for windows.

This would effectifily make all our code posix code. Are we everywhere posix compatible ?

raster added a comment.May 7 2019, 2:55 AM

so do you think that there is a problem if we define _POSIX_C_SOURCE just before including time.h in Elementary.h and Efl_UI.h ?

Yes - this is a public header and this would affect APPLICATIONS that use elementary and effectively force this define on their later includes and source. It will probably have unintended side-effects. We'd have to do this within the efl build tree/build only so...

to make it short, i would like to pass -D_POSIX_C_SOURCE to cflags for the whole project. If you think it's too much, we can pass -D_POSIX_C_SOURCE only for windows.

That is better and more like it.

This would effectifily make all our code posix code. Are we everywhere posix compatible ?

Well we assume a POSIX system and try and write to that as a standard... so... :)

vtorri added a comment.May 7 2019, 3:00 AM

@bu5hm4n so

add_global_arguments('-D_POSIX_C_SOURCE=1', language: lang)

in toplevel meson.build (just after _GNU_SOURCE for example) would be good for you ?

vtorri closed this task as Resolved.May 8 2019, 8:53 AM