Skip to content

Remove _CRT_SECURE_NO_WARNINGS#774

Open
Youw wants to merge 2 commits intomasterfrom
dev-remove-crt-secure
Open

Remove _CRT_SECURE_NO_WARNINGS#774
Youw wants to merge 2 commits intomasterfrom
dev-remove-crt-secure

Conversation

@Youw
Copy link
Member

@Youw Youw commented Mar 1, 2026

  • use *_s version of swprintf/wcsncpy/sscanf when possible

Fixes: #770

@Youw Youw requested a review from Copilot March 1, 2026 18:43
@Youw Youw marked this pull request as draft March 1, 2026 18:44
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR removes reliance on _CRT_SECURE_NO_WARNINGS in the Windows backend by switching to MSVC “secure CRT” function variants where appropriate, addressing MSVC warning noise reported in #770.

Changes:

  • Removed _CRT_SECURE_NO_WARNINGS defines from Windows source/header files.
  • Introduced MSVC-version-gated wrappers to use swprintf_s / wcsncpy_s in windows/hid.c.
  • Updated the Windows HID report reconstructor test to use sscanf_s (with required buffer-size args) when building with MSVC.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
windows/test/hid_report_reconstructor_test.c Uses sscanf_s on MSVC (and passes scanset buffer sizes) to avoid CRT “unsafe” warnings.
windows/hidapi_descriptor_reconstruct.h Removes _CRT_SECURE_NO_WARNINGS define block.
windows/hid.c Removes _CRT_SECURE_NO_WARNINGS and uses MSVC secure CRT wrappers for swprintf/wcsncpy.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

- use *_s version of swprintf/wcsncpy/sscanf when possible

Fixes: #770
@Youw Youw force-pushed the dev-remove-crt-secure branch from be3a8a1 to 3a81d4d Compare March 1, 2026 23:20
@Youw Youw added the Windows Related to Windows backend label Mar 1, 2026
@Youw Youw marked this pull request as ready for review March 1, 2026 23:22
@Youw Youw changed the title Attempt to remove _CRT_SECURE_NO_WARNINGS Remove _CRT_SECURE_NO_WARNINGS Mar 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Windows Related to Windows backend

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 Warnings C4047 and C4024 in MSVC

2 participants