Skip to content

tidy-up: TEXT() vs _TEXT() vs _T() use (Windows) - #22334

Closed
vszakats wants to merge 3 commits into
curl:masterfrom
vszakats:wtext
Closed

tidy-up: TEXT() vs _TEXT() vs _T() use (Windows)#22334
vszakats wants to merge 3 commits into
curl:masterfrom
vszakats:wtext

Conversation

@vszakats

@vszakats vszakats commented Jul 15, 2026

Copy link
Copy Markdown
Member

Use _TEXT() when interacting with CRT functions (also prefer over
synonym _T()), TEXT() for Win32 functions.

Within curl, they mean the same because CRT/Win32 Unicode mode are
always enabled in sync.

Ref: https://devblogs.microsoft.com/oldnewthing/20040212-00/?p=40643/


I'm not firmly for _TEXT() over _T(). Just assumed the former is the
official macro based on Raymond not knowing about the short form. We
may stick with the short one, less symmetry, rarer, less greppable, but
shorter. Altogether rarely used in the code.

@vszakats vszakats added Windows Windows-specific tidy-up labels Jul 15, 2026
@vszakats
vszakats requested a review from Copilot July 15, 2026 15:53
@testclutch

This comment was marked as outdated.

Copilot AI left a comment

Copy link
Copy Markdown

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 standardizes Windows TCHAR literal macros to better reflect intent: _TEXT() (preferred over _T()) is used alongside CRT _tcs* functions, while TEXT() remains for Win32 API interactions, aligning with common Windows guidance.

Changes:

  • Replaced _T() with _TEXT() in src/tool_main.c for a CRT _tcscmp() comparison.
  • Replaced TEXT() with _TEXT() in Schannel and SSPI CRT string parsing/comparison code.
  • Updated a Windows path-prefix check in lib/curlx/fopen.c to use _TEXT().

Reviewed changes

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

File Description
src/tool_main.c Uses _TEXT() for the CRT _tcscmp() option check on Windows.
lib/vtls/schannel.c Uses _TEXT() for CRT _tcs* parsing of certificate store location strings.
lib/curlx/fopen.c Uses _TEXT() for the CRT _tcsncmp() check of the \\?\ path prefix.
lib/curl_sspi.c Uses _TEXT() for CRT _tcschr() parsing and empty-string literals in SSPI identity creation.

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

@jay

jay commented Jul 15, 2026

Copy link
Copy Markdown
Member

Any is fine, I've seen all of them used, most projects will define _UNICODE and UNICODE together for Unicode, so even though _T isn't technically the same it's effectively the same.

@vszakats vszakats closed this in 5f2a70a Jul 15, 2026
@vszakats
vszakats deleted the wtext branch July 15, 2026 19:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

4 participants