From patchwork Thu Apr 18 15:36:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eli Zaretskii X-Patchwork-Id: 32336 Received: (qmail 86715 invoked by alias); 18 Apr 2019 15:36:38 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 86691 invoked by uid 89); 18 Apr 2019 15:36:34 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-8.1 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: eggs.gnu.org Received: from eggs.gnu.org (HELO eggs.gnu.org) (209.51.188.92) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 18 Apr 2019 15:36:33 +0000 Received: from fencepost.gnu.org ([2001:470:142:3::e]:33863) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hH95T-0007ib-Oi for gdb-patches@sourceware.org; Thu, 18 Apr 2019 11:36:31 -0400 Received: from [176.228.60.248] (port=3123 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1hH95S-0002Wu-Ld for gdb-patches@sourceware.org; Thu, 18 Apr 2019 11:36:31 -0400 Date: Thu, 18 Apr 2019 18:36:11 +0300 Message-Id: <835zrbe36c.fsf@gnu.org> From: Eli Zaretskii To: gdb-patches@sourceware.org Subject: Fix compilation using mingw.org's MinGW X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-IsSubscribed: yes windows-nat.c uses CONSOLE_FONT_INFO unconditionally, but the corresponding declaration in the Windows API headers is conditional, because the APIs using CONSOLE_FONT_INFO are only available since Windows XP. When that condition doesn't hold, windows-nat.c won't compile: windows-nat.c:114:10: error: 'CONSOLE_FONT_INFO' has not been declared CONSOLE_FONT_INFO *); ^~~~~~~~~~~~~~~~~ windows-nat.c: In function 'void windows_set_console_info(STARTUPINFOA*, DWORD*)': windows-nat.c:2174:7: error: 'CONSOLE_FONT_INFO' was not declared in this scope CONSOLE_FONT_INFO cfi; ^~~~~~~~~~~~~~~~~ windows-nat.c:2174:7: note: suggested alternative: 'CONSOLE_CURSOR_INFO' CONSOLE_FONT_INFO cfi; ^~~~~~~~~~~~~~~~~ CONSOLE_CURSOR_INFO windows-nat.c:2176:48: error: 'cfi' was not declared in this scope GetCurrentConsoleFont (hconsole, FALSE, &cfi); ^~~ windows-nat.c: At global scope: windows-nat.c:3302:55: error: 'CONSOLE_FONT_INFO' has not been declared bad_GetCurrentConsoleFont (HANDLE w, BOOL bMaxWindow, CONSOLE_FONT_INFO *f) ^~~~~~~~~~~~~~~~~ windows-nat.c: In function 'BOOL bad_GetCurrentConsoleFont(HANDLE, BOOL, int*)': windows-nat.c:3304:6: error: request for member 'nFont' in '* f', which is of non-class type 'int' f->nFont = 0; ^~~~~ MinGW64 no longer supports versions of Windows older than XP, but mingw.org's MinGW does. Since we load GetCurrentConsoleFont dynamically at run time, and have code for when the load fails, it makes sense to not assume XP at compile time. The patch below does that. OK to push (with the pertinent ChangeLog entry)? --- gdb/windows-nat.c~0 2019-03-27 00:52:05.000000000 +0200 +++ gdb/windows-nat.c 2019-04-18 11:37:02.061945600 +0300 @@ -81,6 +81,16 @@ #define GetConsoleFontSize dyn_GetConsoleFontSize #define GetCurrentConsoleFont dyn_GetCurrentConsoleFont +#if _WIN32_WINNT < 0x0501 + +typedef +struct _CONSOLE_FONT_INFO +{ DWORD nFont; + COORD dwFontSize; +} CONSOLE_FONT_INFO, *PCONSOLE_FONT_INFO; + +#endif + typedef BOOL WINAPI (AdjustTokenPrivileges_ftype) (HANDLE, BOOL, PTOKEN_PRIVILEGES, DWORD, PTOKEN_PRIVILEGES,