Skip to content

Commit e9c39c1

Browse files
authored
windows.cfg: Fix wrong FlushConsoleInputBuffer configuration (#5526)
After flushing, the function returns. Before it was configured to not-return. A proper regression test was added.
1 parent d48df98 commit e9c39c1

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

cfg/windows.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4791,7 +4791,7 @@ HFONT CreateFont(
47914791
</function>
47924792
<!--BOOL WINAPI FlushConsoleInputBuffer(_In_ HANDLE hConsoleInput);-->
47934793
<function name="FlushConsoleInputBuffer">
4794-
<noreturn>true</noreturn>
4794+
<noreturn>false</noreturn>
47954795
<returnValue type="BOOL"/>
47964796
<leak-ignore/>
47974797
<arg nr="1" direction="in">

test/cfg/windows.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
// No warnings about bad library configuration, unmatched suppressions, etc. exitcode=0
88
//
99

10-
#include <windows.h>
10+
#include <Windows.h>
11+
#include <WinCon.h>
1112
#include <cstdio>
1213
#include <direct.h>
1314
#include <cstdlib>
@@ -18,6 +19,15 @@
1819
#include <atlstr.h>
1920
#include <string>
2021

22+
/// https://learn.microsoft.com/en-us/windows/console/flushconsoleinputbuffer
23+
BOOL unreachableCode_FlushConsoleInputBuffer(int &val)
24+
{
25+
const BOOL retVal = FlushConsoleInputBuffer(GetStdHandle(STD_INPUT_HANDLE));
26+
// still reachable after call FlushConsoleInputBuffer()
27+
val = 42;
28+
return retVal;
29+
}
30+
2131
/// https://learn.microsoft.com/en-us/windows/win32/api/libloaderapi/nf-libloaderapi-getmodulefilenamew
2232
std::string constVariable_GetModuleFileName(void) {
2333
char path[42];

0 commit comments

Comments
 (0)