Wmain compilation error

Asked 2 years ago, Updated 2 years ago, 33 views

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

int wmain(int argc, wchar_t* argv[]) {
    LPSTR str1 = "SBCS Style String 1";
    LPWSTR str2 = L"WBCS Style String 1";

    CHAR arr1[] = "SBCS Style String 1";
    WCHAR arr2[] = L"WBCS Style String 2";

    LPCSTR cStr1 = arr1;
    LPCWSTR cStr2 = arr2;

    printf("%s\n", str1);
    printf("%s\n", arr1);

    wprintf(L"%s\n", str2);
    wprintf(L"%s\n", arr2);

    return 0;
}

WinString.cpp: In function 'int wmain(int, wchar_t*)': WinString.cpp:5:18: warning: ISO C++ forbids converting a string constant to 'LPSTR {aka char}' [-Wwrite-strings] LPSTR str1 = "SBCS Style String 1"; ~~~~~~~~~~~~~~~~~~~~ WinString.cpp:6:19: warning: ISO C++ forbids converting a string constant to 'LPWSTR {aka wchar_t*}' [-Wwrite-strings] LPWSTR str2 = L"WBCS Style String 1"; ~~~~~~~~~~~~~~~~~~~~~ c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../libmingw32.a(main.o):(.text.startup+0xa0): undefined reference to `WinMain@16' collect2.exe: error: ld returned 1 exit status

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The following error occurs: Compiled with gcc. How do I solve this?

c c++

2022-09-22 14:53

1 Answers

Linker related error.

https://sourceforge.net/p/mingw-w64/wiki2/Unicode%20apps/

Please refer to the link above link.


2022-09-22 14:53

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.