Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Noobie errors! #4

Open
sukhchainn opened this issue Nov 26, 2018 · 4 comments
Open

Noobie errors! #4

sukhchainn opened this issue Nov 26, 2018 · 4 comments

Comments

@sukhchainn
Copy link

When I compiled the program this happened, please tell me what to do.

$ g++ -std=gnu++17 -o game CommandLineFPS.cpp
CommandLineFPS.cpp: In function 'int main()':
CommandLineFPS.cpp:267:114: error: 'swprintf_s' was not declared in this scope
swprintf_s(screen, 40, L"X=%3.2f, Y=%3.2f, A=%3.2f FPS=%3.2f ", fPlayerX, fPlayerY, fPlayerA, 1.0f/fElapsedTime);
^
CommandLineFPS.cpp:279:103: error: cannot convert 'wchar_t*' to 'LPCSTR {aka const char*}' for argument '2' to 'BOOL WriteConsoleOutputCharacterA(HANDLE, LPCSTR, DWORD, COORD, PDWORD)'
WriteConsoleOutputCharacter(hConsole, screen, nScreenWidth * nScreenHeight, { 0,0 }, &dwBytesWritten);
^

@NotSoSmartGames
Copy link

I'm not sure what you need to do in *nix but for Visual Studio you need to change the compiler over to UNICODE. To do this you goto Project -> Properties -> General -> Character Set -> Use Unicode Character Set.

Here is a link that talks about changing the character set for g++:
https://gcc.gnu.org/onlinedocs/cpp/Character-sets.html

@ghost
Copy link

ghost commented Jul 2, 2019

I tried to compile this in CodeBlocks and it does not work. What do I do?

@minh25
Copy link

minh25 commented Aug 12, 2019

I don't know how to compile this in cmd. Please tell me what to do.

@Altareon98
Copy link

Altareon98 commented Jul 25, 2020

@Quake504
In case that you still need to solve this...

I tried the option posted here https://stackoverflow.com/questions/61880906/c-errorinvalid-conversion-from-int-to-const-wchar-t-because-of-swprintf

Just add a W to the method: WriteConsoleOutputCharacter(...) -> WriteConsoleOutputCharacterW(...) and it must work when you try to compile it on Code Blocks. It worked for me ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants