Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes #18896; fixes #20886; importc types alias doesn't work with distinct #24313

Merged
merged 2 commits into from
Oct 16, 2024

Conversation

ringabout
Copy link
Member

@ringabout ringabout commented Oct 15, 2024

fixes #18896
fixes #20886

type
  PFile {.importc: "FILE*", header: "<stdio.h>".} = distinct pointer
    # import C's FILE* type; Nim will treat it as a new pointer type

This is an excerpt from the Nim manual. In the old Nim versions, it produces a void pointer type instead of the FILE* type that should have been generated. Because these C types tend to be opaque and adapt to changes on different platforms. It might affect the portability of Nim on various OS, i.e. csource_v2 cannot build on the apline platform because of Time relies on Nim types instead of the time_t type.

ref #18851

@ringabout ringabout changed the title fixes #18896; importc types alias doesn't work with distinct fixes #18896; fixes #20886; importc types alias doesn't work with distinct Oct 15, 2024
@ringabout ringabout marked this pull request as ready for review October 15, 2024 13:53
@Araq Araq merged commit 8be82c3 into devel Oct 16, 2024
19 checks passed
@Araq Araq deleted the pr_distinct_c_aliases branch October 16, 2024 18:49
Copy link
Contributor

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

Hint: mm: orc; opt: speed; options: -d:release
175264 lines; 8.308s; 655.316MiB peakmem

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.

nimsuggest: failed to build with clang on musl libc importc types alias doesn't work with distinct
2 participants