使用MinGW GCC更改Windows CMD上的代码页时,将_POSIX_C_SOURCE定义为2会导致错误

使用MinGW GCC更改Windows CMD上的代码页时,将_POSIX_C_SOURCE定义为2会导致错误,c,cmd,mingw,codepages,C,Cmd,Mingw,Codepages,我一直在写一个Linux程序,打算在终端上写非英语字符,最近我把它移植到Windows上,我遇到了一些问题,当我试图更改终端的代码页和字体时,使用先前定义的符号常量_POSIX_C_SOURCE似乎改变了代码的行为,并使其无法正确打印非英语字符,仅供参考,这是我的代码 #include <windows.h> #include <stdio.h> int main() { SetConsoleCP(CP_UTF8) SetConsoleOutputCP(

我一直在写一个Linux程序,打算在终端上写非英语字符,最近我把它移植到Windows上,我遇到了一些问题,当我试图更改终端的代码页和字体时,使用先前定义的符号常量_POSIX_C_SOURCE似乎改变了代码的行为,并使其无法正确打印非英语字符,仅供参考,这是我的代码

#include <windows.h>
#include <stdio.h>

int main()
{
    SetConsoleCP(CP_UTF8)
    SetConsoleOutputCP(CP_UTF8)

    HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
    CONSOLE_FONT_INFOEX cfie;
    ZeroMemory(&cfie, sizeof(cfie));
    cfie.cbSize = sizeof(cfie);
    lstrcpyW(cfie.FaceName, L"Lucida Console");
    SetCurrentConsoleFontEx(hStdOut, 0, &cfie);
    printf("Ћирилични текст\n");

    return 0;
}

这是因为当POSIX合规性生效时,标准输出的输出是逐字节进行的。它使用了一个不同的实现,在
printf
函数中完成了什么。

所以除了删除宏,我没有别的选择了?
C:\Users\User\Desktop>gcc test.c

C:\Users\User\Desktop>a.exe
Ћириличан текст

C:\Users\User\Desktop>gcc -D_POSIX_C_SOURCE=2 test.c

C:\Users\User\Desktop>a.exe
������������������ ����������