【问题标题】:Getting weird struct and typedef errors in Win consoleapi using MinGW-w64使用 MinGW-w64 在 Win consoleapi 中获取奇怪的结构和 typedef 错误
【发布时间】:2020-12-15 04:54:58
【问题描述】:

下面是编译日志。所有这些错误都来自 Wincon.h 或 Wincontypes.h 。其他一切,包括我的代码,都有效。我正在使用 MinGW-w64 (v8.1.0),它不会为 Winapi 或 ConsoleApi3 提供任何错误。在这一点上我很无助。 Visual Studio (MSBuild) 编译它没有问题。

g++ MainConsole.cpp -o run -mconsole
In file included from C:/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/ConsoleApi3.h:21,
                 from F:\PROJECTS\gpge\GPGE\Dependencies.h:7,
                 from MainConsole.cpp:6:
C:/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/wincontypes.h:36:16: error: redefinition of 'struct _COORD'
 typedef struct _COORD {
                ^~~~~~
In file included from C:/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/x86_64-w64-mingw32/include/Windows.h:74,
                 from F:\PROJECTS\gpge\GPGE\Dependencies.h:5,
                 from MainConsole.cpp:6:
C:/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/x86_64-w64-mingw32/include/wincon.h:17:18: note: previous definition of 'struct _COORD'
   typedef struct _COORD {
                  ^~~~~~


In file included from C:/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/x86_64-w64-mingw32/include/Windows.h:74,
                 from F:\PROJECTS\gpge\GPGE\Dependencies.h:5,
                 from MainConsole.cpp:6:
C:/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/x86_64-w64-mingw32/include/wincon.h:22:18: note: previous definition of 'struct _SMALL_RECT'
   typedef struct _SMALL_RECT {
                  ^~~~~~~~~~~
In file included from C:/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/ConsoleApi3.h:21,
                 from F:\PROJECTS\gpge\GPGE\Dependencies.h:7,
                 from MainConsole.cpp:6:
C:/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/wincontypes.h:46:3: error: conflicting declaration 'typedef int SMALL_RECT'
 } SMALL_RECT, *PSMALL_RECT;
   ^~~~~~~~~~
In file included from C:/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/x86_64-w64-mingw32/include/Windows.h:74,
                 from F:\PROJECTS\gpge\GPGE\Dependencies.h:5,
                 from MainConsole.cpp:6:

In file included from C:/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/x86_64-w64-mingw32/include/Windows.h:74,
                 from F:\PROJECTS\gpge\GPGE\Dependencies.h:5,
                 from MainConsole.cpp:6:
C:/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/x86_64-w64-mingw32/include/wincon.h:27:17: note: previous declaration as 'typedef struct _SMALL_RECT* PSMALL_RECT'
   } SMALL_RECT,*PSMALL_RECT;
                 ^~~~~~~~~~~
In file included from C:/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/x86_64-w64-mingw32/include/Windows.h:74,
                 from F:\PROJECTS\gpge\GPGE\Dependencies.h:5,
                 from MainConsole.cpp:6:
C:/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/x86_64-w64-mingw32/include/wincon.h:78:18: note: previous definition of 'struct _WINDOW_BUFFER_SIZE_RECORD'
   typedef struct _WINDOW_BUFFER_SIZE_RECORD {
                  ^~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from C:/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/ConsoleApi3.h:21,
                 from F:\PROJECTS\gpge\GPGE\Dependencies.h:7,
                 from MainConsole.cpp:6:
C:/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/wincontypes.h:112:3: error: conflicting declaration 'typedef int WINDOW_BUFFER_SIZE_RECORD'
 } WINDOW_BUFFER_SIZE_RECORD, *PWINDOW_BUFFER_SIZE_RECORD;
   ^~~~~~~~~~~~~~~~~~~~~~~~~
In file included from C:/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/x86_64-w64-mingw32/include/Windows.h:74,
                 from F:\PROJECTS\gpge\GPGE\Dependencies.h:5,
                 from MainConsole.cpp:6:
C:/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/x86_64-w64-mingw32/include/wincon.h:80:5: note: previous declaration as 'typedef struct _WINDOW_BUFFER_SIZE_RECORD WINDOW_BUFFER_SIZE_RECORD'
   } WINDOW_BUFFER_SIZE_RECORD,*PWINDOW_BUFFER_SIZE_RECORD;
     ^~~~~~~~~~~~~~~~~~~~~~~~~
In file included from C:/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/ConsoleApi3.h:21,
                 from F:\PROJECTS\gpge\GPGE\Dependencies.h:7,
                 from MainConsole.cpp:6:
C:/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/wincontypes.h:112:31: error: conflicting declaration 'typedef int* PWINDOW_BUFFER_SIZE_RECORD'
 } WINDOW_BUFFER_SIZE_RECORD, *PWINDOW_BUFFER_SIZE_RECORD;
                               ^~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from C:/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/x86_64-w64-mingw32/include/Windows.h:74,
                 from F:\PROJECTS\gpge\GPGE\Dependencies.h:5,
                 from MainConsole.cpp:6:
C:/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/x86_64-w64-mingw32/include/wincon.h:80:32: note: previous declaration as 'typedef struct _WINDOW_BUFFER_SIZE_RECORD* PWINDOW_BUFFER_SIZE_RECORD'
   } WINDOW_BUFFER_SIZE_RECORD,*PWINDOW_BUFFER_SIZE_RECORD;
                                ^~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from C:/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/ConsoleApi3.h:21,
                 from F:\PROJECTS\gpge\GPGE\Dependencies.h:7,
                 from MainConsole.cpp:6:
C:/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/wincontypes.h:114:16: error: redefinition of 'struct _MENU_EVENT_RECORD'
 typedef struct _MENU_EVENT_RECORD {
                ^~~~~~~~~~~~~~~~~~
In file included from C:/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/x86_64-w64-mingw32/include/Windows.h:74,
                 from F:\PROJECTS\gpge\GPGE\Dependencies.h:5,
                 from MainConsole.cpp:6:
C:/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/x86_64-w64-mingw32/include/wincon.h:82:18: note: previous definition of 'struct _MENU_EVENT_RECORD'
   typedef struct _MENU_EVENT_RECORD {
                  ^~~~~~~~~~~~~~~~~~
In file included from C:/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/ConsoleApi3.h:21,
                 from F:\PROJECTS\gpge\GPGE\Dependencies.h:7,
                 from MainConsole.cpp:6:
C:/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/wincontypes.h:116:3: error: conflicting declaration 'typedef int MENU_EVENT_RECORD'
 } MENU_EVENT_RECORD, *PMENU_EVENT_RECORD;
   ^~~~~~~~~~~~~~~~~
In file included from C:/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/x86_64-w64-mingw32/include/Windows.h:74,
                 from F:\PROJECTS\gpge\GPGE\Dependencies.h:5,
                 from MainConsole.cpp:6:
C:/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/x86_64-w64-mingw32/include/wincon.h:84:5: note: previous declaration as 'typedef struct _MENU_EVENT_RECORD MENU_EVENT_RECORD'
   } MENU_EVENT_RECORD,*PMENU_EVENT_RECORD;
     ^~~~~~~~~~~~~~~~~
In file included from C:/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/ConsoleApi3.h:21,
                 from F:\PROJECTS\gpge\GPGE\Dependencies.h:7,
                 from MainConsole.cpp:6:
C:/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/wincontypes.h:116:23: error: conflicting declaration 'typedef int* PMENU_EVENT_RECORD'
 } MENU_EVENT_RECORD, *PMENU_EVENT_RECORD;
                       ^~~~~~~~~~~~~~~~~~
In file included from C:/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/x86_64-w64-mingw32/include/Windows.h:74,
                 from F:\PROJECTS\gpge\GPGE\Dependencies.h:5,
                 from MainConsole.cpp:6:
C:/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/x86_64-w64-mingw32/include/wincon.h:84:24: note: previous declaration as 'typedef struct _MENU_EVENT_RECORD* PMENU_EVENT_RECORD'
   } MENU_EVENT_RECORD,*PMENU_EVENT_RECORD;
                        ^~~~~~~~~~~~~~~~~~
In file included from C:/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/ConsoleApi3.h:21,
                 from F:\PROJECTS\gpge\GPGE\Dependencies.h:7,
                 from MainConsole.cpp:6:
C:/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/wincontypes.h:118:16: error: redefinition of 'struct _FOCUS_EVENT_RECORD'
 typedef struct _FOCUS_EVENT_RECORD {
                ^~~~~~~~~~~~~~~~~~~
In file included from C:/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/x86_64-w64-mingw32/include/Windows.h:74,
                 from F:\PROJECTS\gpge\GPGE\Dependencies.h:5,
                 from MainConsole.cpp:6:
C:/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/x86_64-w64-mingw32/include/wincon.h:86:18: note: previous definition of 'struct _FOCUS_EVENT_RECORD'
   typedef struct _FOCUS_EVENT_RECORD {
                  ^~~~~~~~~~~~~~~~~~~
In file included from C:/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/ConsoleApi3.h:21,
                 from F:\PROJECTS\gpge\GPGE\Dependencies.h:7,
                 from MainConsole.cpp:6:
C:/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/wincontypes.h:120:3: error: conflicting declaration 'typedef int FOCUS_EVENT_RECORD'
 } FOCUS_EVENT_RECORD, *PFOCUS_EVENT_RECORD;
   ^~~~~~~~~~~~~~~~~~
In file included from C:/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/x86_64-w64-mingw32/include/Windows.h:74,
                 from F:\PROJECTS\gpge\GPGE\Dependencies.h:5,
                 from MainConsole.cpp:6:
C:/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/x86_64-w64-mingw32/include/wincon.h:88:5: note: previous declaration as 'typedef struct _FOCUS_EVENT_RECORD FOCUS_EVENT_RECORD'
   } FOCUS_EVENT_RECORD,*PFOCUS_EVENT_RECORD;
     ^~~~~~~~~~~~~~~~~~
In file included from C:/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/ConsoleApi3.h:21,
                 from F:\PROJECTS\gpge\GPGE\Dependencies.h:7,
                 from MainConsole.cpp:6:
C:/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/wincontypes.h:120:24: error: conflicting declaration 'typedef int* PFOCUS_EVENT_RECORD'
 } FOCUS_EVENT_RECORD, *PFOCUS_EVENT_RECORD;
                        ^~~~~~~~~~~~~~~~~~~
In file included from C:/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/x86_64-w64-mingw32/include/Windows.h:74,
                 from F:\PROJECTS\gpge\GPGE\Dependencies.h:5,
                 from MainConsole.cpp:6:
C:/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/x86_64-w64-mingw32/include/wincon.h:88:25: note: previous declaration as 'typedef struct _FOCUS_EVENT_RECORD* PFOCUS_EVENT_RECORD'
   } FOCUS_EVENT_RECORD,*PFOCUS_EVENT_RECORD;
                         ^~~~~~~~~~~~~~~~~~~
In file included from C:/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/ConsoleApi3.h:21,
                 from F:\PROJECTS\gpge\GPGE\Dependencies.h:7,
                 from MainConsole.cpp:6:
C:/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/wincontypes.h:122:16: error: redefinition of 'struct _INPUT_RECORD'
 typedef struct _INPUT_RECORD {
                ^~~~~~~~~~~~~
In file included from C:/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/x86_64-w64-mingw32/include/Windows.h:74,
                 from F:\PROJECTS\gpge\GPGE\Dependencies.h:5,
                 from MainConsole.cpp:6:
C:/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/x86_64-w64-mingw32/include/wincon.h:90:18: note: previous definition of 'struct _INPUT_RECORD'
   typedef struct _INPUT_RECORD {
                  ^~~~~~~~~~~~~
In file included from C:/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/ConsoleApi3.h:21,
                 from F:\PROJECTS\gpge\GPGE\Dependencies.h:7,
                 from MainConsole.cpp:6:
C:/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/wincontypes.h:131:3: error: conflicting declaration 'typedef int INPUT_RECORD'
 } INPUT_RECORD, *PINPUT_RECORD;
   ^~~~~~~~~~~~
In file included from C:/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/x86_64-w64-mingw32/include/Windows.h:74,
                 from F:\PROJECTS\gpge\GPGE\Dependencies.h:5,
                 from MainConsole.cpp:6:
C:/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/x86_64-w64-mingw32/include/wincon.h:99:5: note: previous declaration as 'typedef struct _INPUT_RECORD INPUT_RECORD'
   } INPUT_RECORD,*PINPUT_RECORD;
     ^~~~~~~~~~~~
In file included from C:/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/ConsoleApi3.h:21,
                 from F:\PROJECTS\gpge\GPGE\Dependencies.h:7,
                 from MainConsole.cpp:6:
C:/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/wincontypes.h:131:18: error: conflicting declaration 'typedef int* PINPUT_RECORD'
 } INPUT_RECORD, *PINPUT_RECORD;
                  ^~~~~~~~~~~~~
In file included from C:/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/x86_64-w64-mingw32/include/Windows.h:74,
                 from F:\PROJECTS\gpge\GPGE\Dependencies.h:5,
                 from MainConsole.cpp:6:
C:/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/x86_64-w64-mingw32/include/wincon.h:99:19: note: previous declaration as 'typedef struct _INPUT_RECORD* PINPUT_RECORD'
   } INPUT_RECORD,*PINPUT_RECORD;
                   ^~~~~~~~~~~~~
In file included from C:/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/ConsoleApi3.h:21,
                 from F:\PROJECTS\gpge\GPGE\Dependencies.h:7,
                 from MainConsole.cpp:6:
C:/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/wincontypes.h:143:16: error: redefinition of 'struct _CHAR_INFO'
 typedef struct _CHAR_INFO {
                ^~~~~~~~~~
In file included from C:/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/x86_64-w64-mingw32/include/Windows.h:74,
                 from F:\PROJECTS\gpge\GPGE\Dependencies.h:5,
                 from MainConsole.cpp:6:
C:/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/x86_64-w64-mingw32/include/wincon.h:107:18: note: previous definition of 'struct _CHAR_INFO'
   typedef struct _CHAR_INFO {
                  ^~~~~~~~~~
In file included from C:/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/ConsoleApi3.h:21,
                 from F:\PROJECTS\gpge\GPGE\Dependencies.h:7,
                 from MainConsole.cpp:6:
C:/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/wincontypes.h:149:3: error: conflicting declaration 'typedef int CHAR_INFO'
 } CHAR_INFO, *PCHAR_INFO;
   ^~~~~~~~~
In file included from C:/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/x86_64-w64-mingw32/include/Windows.h:74,
                 from F:\PROJECTS\gpge\GPGE\Dependencies.h:5,
                 from MainConsole.cpp:6:
C:/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/x86_64-w64-mingw32/include/wincon.h:113:5: note: previous declaration as 'typedef struct _CHAR_INFO CHAR_INFO'
   } CHAR_INFO,*PCHAR_INFO;
     ^~~~~~~~~
In file included from C:/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/ConsoleApi3.h:21,
                 from F:\PROJECTS\gpge\GPGE\Dependencies.h:7,
                 from MainConsole.cpp:6:
C:/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/wincontypes.h:149:15: error: conflicting declaration 'typedef int* PCHAR_INFO'
 } CHAR_INFO, *PCHAR_INFO;
               ^~~~~~~~~~
In file included from C:/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/x86_64-w64-mingw32/include/Windows.h:74,
                 from F:\PROJECTS\gpge\GPGE\Dependencies.h:5,
                 from MainConsole.cpp:6:
C:/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/x86_64-w64-mingw32/include/wincon.h:113:16: note: previous declaration as 'typedef struct _CHAR_INFO* PCHAR_INFO'
   } CHAR_INFO,*PCHAR_INFO;
                ^~~~~~~~~~
In file included from C:/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/ConsoleApi3.h:21,
                 from F:\PROJECTS\gpge\GPGE\Dependencies.h:7,
                 from MainConsole.cpp:6:
C:/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/wincontypes.h:151:16: error: redefinition of 'struct _CONSOLE_FONT_INFO'
 typedef struct _CONSOLE_FONT_INFO {
                ^~~~~~~~~~~~~~~~~~
In file included from C:/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/x86_64-w64-mingw32/include/Windows.h:74,
                 from F:\PROJECTS\gpge\GPGE\Dependencies.h:5,
                 from MainConsole.cpp:6:
C:/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/x86_64-w64-mingw32/include/wincon.h:146:18: note: previous definition of 'struct _CONSOLE_FONT_INFO'
   typedef struct _CONSOLE_FONT_INFO {
                  ^~~~~~~~~~~~~~~~~~
In file included from C:/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/ConsoleApi3.h:21,
                 from F:\PROJECTS\gpge\GPGE\Dependencies.h:7,
                 from MainConsole.cpp:6:
C:/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/wincontypes.h:154:3: error: conflicting declaration 'typedef int CONSOLE_FONT_INFO'
 } CONSOLE_FONT_INFO, *PCONSOLE_FONT_INFO;
   ^~~~~~~~~~~~~~~~~
In file included from C:/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/x86_64-w64-mingw32/include/Windows.h:74,
                 from F:\PROJECTS\gpge\GPGE\Dependencies.h:5,
                 from MainConsole.cpp:6:
C:/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/x86_64-w64-mingw32/include/wincon.h:149:5: note: previous declaration as 'typedef struct _CONSOLE_FONT_INFO CONSOLE_FONT_INFO'
   } CONSOLE_FONT_INFO,*PCONSOLE_FONT_INFO;
     ^~~~~~~~~~~~~~~~~
In file included from C:/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/ConsoleApi3.h:21,
                 from F:\PROJECTS\gpge\GPGE\Dependencies.h:7,
                 from MainConsole.cpp:6:
C:/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/wincontypes.h:154:23: error: conflicting declaration 'typedef int* PCONSOLE_FONT_INFO'
 } CONSOLE_FONT_INFO, *PCONSOLE_FONT_INFO;
                       ^~~~~~~~~~~~~~~~~~
In file included from C:/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/x86_64-w64-mingw32/include/Windows.h:74,
                 from F:\PROJECTS\gpge\GPGE\Dependencies.h:5,
                 from MainConsole.cpp:6:
C:/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/x86_64-w64-mingw32/include/wincon.h:149:24: note: previous declaration as 'typedef struct _CONSOLE_FONT_INFO* PCONSOLE_FONT_INFO'
   } CONSOLE_FONT_INFO,*PCONSOLE_FONT_INFO;
                        ^~~~~~~~~~~~~~~~~~
In file included from F:\PROJECTS\gpge\GPGE\Dependencies.h:7,
                 from MainConsole.cpp:6:
C:/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/ConsoleApi3.h:66:16: error: redefinition of 'struct _CONSOLE_FONT_INFOEX'
 typedef struct _CONSOLE_FONT_INFOEX {
                ^~~~~~~~~~~~~~~~~~~~
In file included from C:/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/x86_64-w64-mingw32/include/Windows.h:74,
                 from F:\PROJECTS\gpge\GPGE\Dependencies.h:5,
                 from MainConsole.cpp:6:
C:/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/x86_64-w64-mingw32/include/wincon.h:297:16: note: previous definition of 'struct _CONSOLE_FONT_INFOEX'
 typedef struct _CONSOLE_FONT_INFOEX {
                ^~~~~~~~~~~~~~~~~~~~
In file included from F:\PROJECTS\gpge\GPGE\Dependencies.h:7,
                 from MainConsole.cpp:6:
C:/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/ConsoleApi3.h:73:3: error: conflicting declaration 'typedef int CONSOLE_FONT_INFOEX'
 } CONSOLE_FONT_INFOEX, *PCONSOLE_FONT_INFOEX;
   ^~~~~~~~~~~~~~~~~~~
In file included from C:/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/x86_64-w64-mingw32/include/Windows.h:74,
                 from F:\PROJECTS\gpge\GPGE\Dependencies.h:5,
                 from MainConsole.cpp:6:
C:/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/x86_64-w64-mingw32/include/wincon.h:304:3: note: previous declaration as 'typedef struct _CONSOLE_FONT_INFOEX CONSOLE_FONT_INFOEX'
 } CONSOLE_FONT_INFOEX, *PCONSOLE_FONT_INFOEX;
   ^~~~~~~~~~~~~~~~~~~
In file included from F:\PROJECTS\gpge\GPGE\Dependencies.h:7,
                 from MainConsole.cpp:6:
C:/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/ConsoleApi3.h:73:25: error: conflicting declaration 'typedef int* PCONSOLE_FONT_INFOEX'
 } CONSOLE_FONT_INFOEX, *PCONSOLE_FONT_INFOEX;
                         ^~~~~~~~~~~~~~~~~~~~
In file included from C:/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/x86_64-w64-mingw32/include/Windows.h:74,
                 from F:\PROJECTS\gpge\GPGE\Dependencies.h:5,
                 from MainConsole.cpp:6:
C:/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/x86_64-w64-mingw32/include/wincon.h:304:25: note: previous declaration as 'typedef struct _CONSOLE_FONT_INFOEX* PCONSOLE_FONT_INFOEX'
 } CONSOLE_FONT_INFOEX, *PCONSOLE_FONT_INFOEX;
                         ^~~~~~~~~~~~~~~~~~~~
In file included from F:\PROJECTS\gpge\GPGE\Dependencies.h:7,
                 from MainConsole.cpp:6:
C:/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/ConsoleApi3.h:107:16: error: redefinition of 'struct _CONSOLE_SELECTION_INFO'
 typedef struct _CONSOLE_SELECTION_INFO {
                ^~~~~~~~~~~~~~~~~~~~~~~
In file included from C:/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/x86_64-w64-mingw32/include/Windows.h:74,
                 from F:\PROJECTS\gpge\GPGE\Dependencies.h:5,
                 from MainConsole.cpp:6:
C:/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/x86_64-w64-mingw32/include/wincon.h:151:18: note: previous definition of 'struct _CONSOLE_SELECTION_INFO'
   typedef struct _CONSOLE_SELECTION_INFO {
                  ^~~~~~~~~~~~~~~~~~~~~~~
In file included from F:\PROJECTS\gpge\GPGE\Dependencies.h:7,
                 from MainConsole.cpp:6:
C:/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/ConsoleApi3.h:111:3: error: conflicting declaration 'typedef int CONSOLE_SELECTION_INFO'
 } CONSOLE_SELECTION_INFO, *PCONSOLE_SELECTION_INFO;
   ^~~~~~~~~~~~~~~~~~~~~~
In file included from C:/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/x86_64-w64-mingw32/include/Windows.h:74,
                 from F:\PROJECTS\gpge\GPGE\Dependencies.h:5,
                 from MainConsole.cpp:6:
C:/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/x86_64-w64-mingw32/include/wincon.h:155:5: note: previous declaration as 'typedef struct _CONSOLE_SELECTION_INFO CONSOLE_SELECTION_INFO'
   } CONSOLE_SELECTION_INFO,*PCONSOLE_SELECTION_INFO;
     ^~~~~~~~~~~~~~~~~~~~~~
In file included from F:\PROJECTS\gpge\GPGE\Dependencies.h:7,
                 from MainConsole.cpp:6:
C:/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/ConsoleApi3.h:111:28: error: conflicting declaration 'typedef int* PCONSOLE_SELECTION_INFO'
 } CONSOLE_SELECTION_INFO, *PCONSOLE_SELECTION_INFO;
                            ^~~~~~~~~~~~~~~~~~~~~~~
In file included from C:/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/x86_64-w64-mingw32/include/Windows.h:74,
                 from F:\PROJECTS\gpge\GPGE\Dependencies.h:5,
                 from MainConsole.cpp:6:
C:/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/x86_64-w64-mingw32/include/wincon.h:155:29: note: previous declaration as 'typedef struct _CONSOLE_SELECTION_INFO* PCONSOLE_SELECTION_INFO'
   } CONSOLE_SELECTION_INFO,*PCONSOLE_SELECTION_INFO;
                             ^~~~~~~~~~~~~~~~~~~~~~~
In file included from F:\PROJECTS\gpge\GPGE\Dependencies.h:7,
                 from MainConsole.cpp:6:
C:/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/ConsoleApi3.h:127:16: error: redefinition of 'struct _CONSOLE_HISTORY_INFO'
 typedef struct _CONSOLE_HISTORY_INFO {
                ^~~~~~~~~~~~~~~~~~~~~
In file included from C:/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/x86_64-w64-mingw32/include/Windows.h:74,
                 from F:\PROJECTS\gpge\GPGE\Dependencies.h:5,
                 from MainConsole.cpp:6:
C:/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/x86_64-w64-mingw32/include/wincon.h:306:16: note: previous definition of 'struct _CONSOLE_HISTORY_INFO'
 typedef struct _CONSOLE_HISTORY_INFO {
                ^~~~~~~~~~~~~~~~~~~~~
In file included from F:\PROJECTS\gpge\GPGE\Dependencies.h:7,
                 from MainConsole.cpp:6:
C:/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/ConsoleApi3.h:132:3: error: conflicting declaration 'typedef int CONSOLE_HISTORY_INFO'
 } CONSOLE_HISTORY_INFO, *PCONSOLE_HISTORY_INFO;
   ^~~~~~~~~~~~~~~~~~~~
In file included from C:/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/x86_64-w64-mingw32/include/Windows.h:74,
                 from F:\PROJECTS\gpge\GPGE\Dependencies.h:5,
                 from MainConsole.cpp:6:
C:/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/x86_64-w64-mingw32/include/wincon.h:311:3: note: previous declaration as 'typedef struct _CONSOLE_HISTORY_INFO CONSOLE_HISTORY_INFO'
 } CONSOLE_HISTORY_INFO, *PCONSOLE_HISTORY_INFO;
   ^~~~~~~~~~~~~~~~~~~~
In file included from F:\PROJECTS\gpge\GPGE\Dependencies.h:7,
                 from MainConsole.cpp:6:
C:/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/ConsoleApi3.h:132:26: error: conflicting declaration 'typedef int* PCONSOLE_HISTORY_INFO'
 } CONSOLE_HISTORY_INFO, *PCONSOLE_HISTORY_INFO;
                          ^~~~~~~~~~~~~~~~~~~~~
In file included from C:/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/x86_64-w64-mingw32/include/Windows.h:74,
                 from F:\PROJECTS\gpge\GPGE\Dependencies.h:5,
                 from MainConsole.cpp:6:
C:/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/x86_64-w64-mingw32/include/wincon.h:311:26: note: previous declaration as 'typedef struct _CONSOLE_HISTORY_INFO* PCONSOLE_HISTORY_INFO'
 } CONSOLE_HISTORY_INFO, *PCONSOLE_HISTORY_INFO;

【问题讨论】:

  • 您能否创建一个minimal reproducible exampleedit 来展示您的问题?
  • @Someprogrammerdude 你明白这就是问题所在。所有错误都在 Windows api 中,所以它们不在我的控制范围内。我可以创建一个使用 AllocConsole() 的简单应用程序,但这会导致完全相同数量的错误。问题不在于我的代码(我用 MSBuild 检查过),而是编译器只是不理解 Wincontypes.h 中的一些引用
  • 错误的根本原因不太可能在系统标头中。你的代码很可能有错误。
  • AFAIK,如果包含“Windows.h”,则不需要明确包含“ConsoleApi3.h”。 mingw 标头可能有些问题,但更可能是由于您的代码在包含这些标头之前所做的某些事情造成的。
  • @molbdnilo 这就是解决方案!非常感谢!我注释掉了 ConsoleApi3 包含,现在它编译完美!!!

标签: c++ gcc compiler-errors


【解决方案1】:

“AFAIK,如果包含“Windows.h”,则不需要显式包含“ConsoleApi3.h”。mingw 标头可能有些问题,但更有可能是由某些原因引起的您的代码在包含这些标头之前所做的事情。” -- @molbdnilo 有解决方案。这对我来说是新的,看起来 MSBuild 在编译之前检查了重叠,MinGW 没有。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-11-19
    • 2021-08-15
    • 1970-01-01
    • 2012-02-05
    • 1970-01-01
    相关资源
    最近更新 更多