Skip to content

windows: prefer 64-bit time_t#25666

Merged
Araq merged 1 commit intonim-lang:develfrom
arnetheduck:timet
Mar 31, 2026
Merged

windows: prefer 64-bit time_t#25666
Araq merged 1 commit intonim-lang:develfrom
arnetheduck:timet

Conversation

@arnetheduck
Copy link
Copy Markdown
Contributor

time_t should be a 64-bit type on all relevant windows CRT versions including mingw-w64 - MSDN recommends against using the 32-bit version which only is happens when _USE_32BIT_TIME_T is explicitly defined - instead of guessing (and guessing wrong, as happens with recent mingw versions), we can simply use the 64-bit version always.

time_t should be a 64-bit type on all relevant windows CRT versions
including mingw-w64 - MSDN recommends against using the 32-bit version
which only is happens when `_USE_32BIT_TIME_T` is explicitly defined -
instead of guessing (and guessing wrong, as happens with recent mingw
versions), we can simply use the 64-bit version always.
Comment thread lib/std/time_t.nim
# and 64-bit versions of windows:
# https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/time-time32-time64
# For the avoidance of doubt, always use 64-bit version
type Time* {.importc: "__time64_t", header: "<time.h>".} = distinct clonglong
Copy link
Copy Markdown
Member

@Araq Araq Mar 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can cause subtle regressions due to

type
  clonglong* {.importc: "long long", nodecl.} = int64

where the importc affect generic instance caching. Of course this could also simply mean more code now works correctly thanks to that. So we don't know if the benefits outweigh the risks. (God do I love the fact that we produce C code instead of simply targetting the ABI...)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hm - problem is, the current version doesn't compile at all with recent mingw-i686 since clong != clonglong on the C size

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Araq Araq merged commit e53058d into nim-lang:devel Mar 31, 2026
18 checks passed
@github-actions
Copy link
Copy Markdown
Contributor

Thanks for your hard work on this PR!
The lines below are statistics of the Nim compiler built from e53058d

Hint: mm: orc; opt: speed; options: -d:release
189937 lines; 11.647s; 803.16MiB peakmem

narimiran pushed a commit that referenced this pull request Apr 1, 2026
time_t should be a 64-bit type on all relevant windows CRT versions
including mingw-w64 - MSDN recommends against using the 32-bit version
which only is happens when `_USE_32BIT_TIME_T` is explicitly defined -
instead of guessing (and guessing wrong, as happens with recent mingw
versions), we can simply use the 64-bit version always.

(cherry picked from commit e53058d)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants