[PR #871] [MERGED] Fix signatures of some callback functions #24353

Open
opened 2026-01-31 09:02:46 +00:00 by claunia · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/microsoft/terminal/pull/871
Author: @beevvy
Created: 5/17/2019
Status: Merged
Merged: 5/17/2019
Merged by: @undefined

Base: masterHead: function-signatures


📝 Commits (3)

  • 3de8c24 Fix signatures of callback functions
  • 5a9f4b5 Fix calling conventions of callback functions
  • baa7c96 Remove now-unnecessary casts of pointers to callback functions

📊 Changes

29 files changed (+52 additions, -49 deletions)

View changed files

📝 src/cascadia/TerminalConnection/ConhostConnection.cpp (+2 -2)
📝 src/cascadia/TerminalConnection/ConhostConnection.h (+1 -1)
📝 src/cascadia/TerminalConnection/ConptyConnection.cpp (+2 -2)
📝 src/cascadia/TerminalConnection/ConptyConnection.h (+1 -1)
📝 src/host/CursorBlinker.cpp (+2 -2)
📝 src/host/PtySignalInputThread.cpp (+2 -2)
📝 src/host/PtySignalInputThread.hpp (+1 -1)
📝 src/host/VtInputThread.cpp (+2 -2)
📝 src/host/VtInputThread.hpp (+1 -1)
📝 src/host/srvinit.cpp (+3 -3)
📝 src/interactivity/onecore/ConsoleInputThread.cpp (+2 -2)
📝 src/interactivity/win32/ConsoleInputThread.cpp (+1 -1)
📝 src/interactivity/win32/find.cpp (+2 -2)
📝 src/interactivity/win32/windowio.cpp (+3 -3)
📝 src/interactivity/win32/windowio.hpp (+1 -1)
📝 src/propsheet/ColorControl.cpp (+1 -1)
📝 src/propsheet/ColorControl.h (+1 -1)
📝 src/propsheet/ColorsPage.cpp (+1 -1)
📝 src/propsheet/ColorsPage.h (+1 -1)
📝 src/propsheet/console.cpp (+5 -5)

...and 9 more files

📄 Description

Summary of the Pull Request

This PR fixes a bunch of callback function signatures so that they align with the signatures expected by Windows API. Most changes are from __cdecl to __stdcall, which matters on x86, but not on x64 or ARM64.

PR Checklist

  • Closes #xxx
  • CLA signed. If not, go over here and sign the CLA
  • Tests added/passed
  • Requires documentation to be updated
  • I've discussed this with core contributors already. If not checked, I'm ready to accept this work might be rejected in favor of a different grand plan. Issue number where discussion took place: #xxx

Detailed Description of the Pull Request / Additional comments

I find it hard to believe that conhost.exe as shipped in Windows would use callback functions with incorrect calling convention. Perhaps the version that ships with Windows is compiled with /Gz (__stdcall-by-default)? But OpenConsole.sln isn't.

All of these functions were found manually, so it's likely that there are more issues like this that I didn't find. It would be great if MSVC had a warning similar to GCC's -Wcast-function-type.

The only one signature incompatibility I found that wasn't eliminated was with FONTENUMPROC (I only fixed the calling convention, which is most important anyway), since a slightly different signature is being used that is similar to EnumFontFamProc rather than EnumFontFamExProc/FONTENUMPROC, and a slightly more invasive change would be needed.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/microsoft/terminal/pull/871 **Author:** [@beevvy](https://github.com/beevvy) **Created:** 5/17/2019 **Status:** ✅ Merged **Merged:** 5/17/2019 **Merged by:** [@undefined](undefined) **Base:** `master` ← **Head:** `function-signatures` --- ### 📝 Commits (3) - [`3de8c24`](https://github.com/microsoft/terminal/commit/3de8c24052afbdd1c993f9cffcf6ccd8fec83e19) Fix signatures of callback functions - [`5a9f4b5`](https://github.com/microsoft/terminal/commit/5a9f4b54ff9b634062be11f163f6610910c489da) Fix calling conventions of callback functions - [`baa7c96`](https://github.com/microsoft/terminal/commit/baa7c96aa9a3e2793a506d65e3bdf3d3b364de4f) Remove now-unnecessary casts of pointers to callback functions ### 📊 Changes **29 files changed** (+52 additions, -49 deletions) <details> <summary>View changed files</summary> 📝 `src/cascadia/TerminalConnection/ConhostConnection.cpp` (+2 -2) 📝 `src/cascadia/TerminalConnection/ConhostConnection.h` (+1 -1) 📝 `src/cascadia/TerminalConnection/ConptyConnection.cpp` (+2 -2) 📝 `src/cascadia/TerminalConnection/ConptyConnection.h` (+1 -1) 📝 `src/host/CursorBlinker.cpp` (+2 -2) 📝 `src/host/PtySignalInputThread.cpp` (+2 -2) 📝 `src/host/PtySignalInputThread.hpp` (+1 -1) 📝 `src/host/VtInputThread.cpp` (+2 -2) 📝 `src/host/VtInputThread.hpp` (+1 -1) 📝 `src/host/srvinit.cpp` (+3 -3) 📝 `src/interactivity/onecore/ConsoleInputThread.cpp` (+2 -2) 📝 `src/interactivity/win32/ConsoleInputThread.cpp` (+1 -1) 📝 `src/interactivity/win32/find.cpp` (+2 -2) 📝 `src/interactivity/win32/windowio.cpp` (+3 -3) 📝 `src/interactivity/win32/windowio.hpp` (+1 -1) 📝 `src/propsheet/ColorControl.cpp` (+1 -1) 📝 `src/propsheet/ColorControl.h` (+1 -1) 📝 `src/propsheet/ColorsPage.cpp` (+1 -1) 📝 `src/propsheet/ColorsPage.h` (+1 -1) 📝 `src/propsheet/console.cpp` (+5 -5) _...and 9 more files_ </details> ### 📄 Description ## Summary of the Pull Request This PR fixes a bunch of callback function signatures so that they align with the signatures expected by Windows API. Most changes are from `__cdecl` to `__stdcall`, which matters on x86, but not on x64 or ARM64. <!-- Please review the items on the PR checklist before submitting--> ## PR Checklist * [ ] Closes #xxx * [x] CLA signed. If not, go over [here](https://cla.opensource.microsoft.com/microsoft/Terminal) and sign the CLA * [ ] Tests added/passed * [ ] Requires documentation to be updated * [ ] I've discussed this with core contributors already. If not checked, I'm ready to accept this work might be rejected in favor of a different grand plan. Issue number where discussion took place: #xxx <!-- Provide a more detailed description of the PR, other things fixed or any additional comments/features here --> ## Detailed Description of the Pull Request / Additional comments I find it hard to believe that conhost.exe as shipped in Windows would use callback functions with incorrect calling convention. Perhaps the version that ships with Windows is compiled with `/Gz` (`__stdcall`-by-default)? But OpenConsole.sln isn't. All of these functions were found manually, so it's likely that there are more issues like this that I didn't find. It would be great if MSVC had a warning similar to GCC's `-Wcast-function-type`. The only one signature incompatibility I found that wasn't eliminated was with `FONTENUMPROC` (I only fixed the calling convention, which is most important anyway), since a slightly different signature is being used that is similar to [`EnumFontFamProc`](https://docs.microsoft.com/en-us/previous-versions/dd162621(v%3Dvs.85)) rather than [`EnumFontFamExProc`/`FONTENUMPROC`](https://docs.microsoft.com/en-us/previous-versions//dd162618(v=vs.85)), and a slightly more invasive change would be needed. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
claunia added the pull-request label 2026-01-31 09:02:46 +00:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#24353