Skip to content

windows: Fix insecure CRT warning about getenv. #67

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jeffdav
Copy link
Contributor

@jeffdav jeffdav commented Mar 28, 2025

Building on Windows, I saw:

PS jeffdav\PythonKit> swift build
Building for debugging...
C:\Users\jeffdav\PythonKit\PythonKit\PythonLibrary.swift:287:33: warning: 'getenv' is deprecated: This function or variable may be unsafe. Consider using _dupenv_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. [#DeprecatedDeclaration]
285 |
286 |         var value: String? {
287 |             guard let cString = getenv(key) else { return nil }
    |                                 `- warning: 'getenv' is deprecated: This function or variable may be unsafe. Consider using _dupenv_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. [#DeprecatedDeclaration]

This switches the code to use _dupenv_s() instead, which is pretty straightforward.

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.

1 participant