Skip to content

Import CRT to resolve free on Windows #466

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

Merged
merged 1 commit into from
Mar 14, 2022

Conversation

stevapple
Copy link
Contributor

S:\sourcekit-lsp\Sources\SourceKitD\SKDResponse.swift:55:13: error: cannot find 'free' in scope
    defer { free(ptr) }
            ^~~~
S:\sourcekit-lsp\Sources\SourceKitD\SKDResponseArray.swift:65:13: error: cannot find 'free' in scope
    defer { free(ptr) }
            ^~~~
S:\sourcekit-lsp\Sources\SourceKitD\SKDRequestArray.swift:39:13: error: cannot find 'free' in scope
    defer { free(ptr) }
            ^~~~
S:\sourcekit-lsp\Sources\SourceKitD\SKDRequestDictionary.swift:64:13: error: cannot find 'free' in scope
    defer { free(ptr) }
            ^~~~
S:\sourcekit-lsp\Sources\SourceKitD\SKDResponseDictionary.swift:64:13: error: cannot find 'free' in scope
    defer { free(ptr) }

Copy link
Member

@compnerd compnerd left a comment

Choose a reason for hiding this comment

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

Odd that we haven't hit this so far, but seems like a reasonable thing.

@compnerd
Copy link
Member

@swift-ci please test

@compnerd
Copy link
Member

@stevapple how come this is not needed on Darwin btw? I don't see an import Darwn here.

@stevapple
Copy link
Contributor Author

@compnerd I didn’t figure out yet. It may share the same reason why we didn’t run into it before on Windows.

I guess this could be related with re-exported CStdlib symbols from some modules.

@compnerd
Copy link
Member

Oh, it almost certainly is related to re-exporting. But, it would be good to understand what's the root cause for the change in that.

@stevapple
Copy link
Contributor Author

stevapple commented Mar 14, 2022

But, it would be good to understand what's the root cause for the change in that.

May possibly be related to my fix on C header visibility… I opened this and swiftlang/swift-corelibs-foundation#3151 as preparation for the fix.

@ahoppen
Copy link
Member

ahoppen commented Mar 14, 2022

Windows noob question: Is CRT Window’s C standard library equivalent that defines free etc?

@stevapple
Copy link
Contributor Author

Windows noob question: Is CRT Window’s C standard library equivalent that defines free etc?

It should be a superset of C standard library.

AFAIK the only drawback is that stdint.h is implicitly included in CRT.inttype. For explicit import you should use visualc.stdint instead.

Copy link
Member

@ahoppen ahoppen left a comment

Choose a reason for hiding this comment

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

The change sounds reasonable to me and I trust @compnerd’s judgment that it makes sense from a Windows perspective.

@ahoppen ahoppen merged commit 6295529 into swiftlang:main Mar 14, 2022
@stevapple stevapple deleted the windows-free branch August 1, 2022 14:24
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.

3 participants