Saturday, April 8, 2017

Digest for comp.lang.c++@googlegroups.com - 7 updates in 2 topics

alexo <alessandro.volturno@libero.it>: Apr 08 01:01PM +0200

Il 06/04/2017 18:20, Alf P. Steinbach ha scritto:
> getline( wcin, name );
> wcout << "Pleased to meet you, " << name << "!" << endl;
> }
 
this is the output of my g++ compiler (MinGW)
 
g++ (GCC) 5.3.0
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
And this is the message I get trying to compile your code:
 
 
main.cpp: In function 'void init_streams()':
main.cpp:15:32: error: '_O_WTEXT' was not declared in this scope
_setmode( _fileno( stdin), _O_WTEXT );
^
main.cpp: In function 'int main()':
main.cpp:24:21: error: converting to execution character set: Illegal
byte sequence
auto const& s = L"Every ??? ????? likes Norwegian blåbærsyltetøy!";
^
main.cpp:28:14: error: converting to execution character set: Illegal
byte sequence
wcout << L"What's your name? ";
^
 
 
I've removed all C++11 flavours and I've added
 
#include <cstdio>
 
to turn off a couple of errors about finding stdin and stout.
The problem is that my compiler cannot find _O_WTEXT
and that it doesn't recognize the format L"..." string
Alvin <Alvin@invalid.invalid>: Apr 08 02:01PM +0200

On 2017-04-08 13:01, alexo wrote:
> main.cpp:15:32: error: '_O_WTEXT' was not declared in this scope
> _setmode( _fileno( stdin), _O_WTEXT );
> ^
 
...\x86_64-w64-mingw32\include\fcntl.h:
/**
* This file has no copyright assigned and is placed in the Public Domain.
* This file is part of the mingw-w64 runtime package.
* No warranty is given; refer to the file DISCLAIMER.PD within this
package.
*/
...
#define _O_WTEXT 0x10000
...
 
> byte sequence
> wcout << L"What's your name? ";
> ^
 
That's the kind of error you get, if you didn't properly create the .cpp
as UTF-8.
 
 
> to turn off a couple of errors about finding stdin and stout.
> The problem is that my compiler cannot find _O_WTEXT
> and that it doesn't recognize the format L"..." string
 
The original code works with the MinGW 5.x and 6.x versions I have lying
around.
"Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com>: Apr 08 03:05PM +0200

On 08-Apr-17 1:01 PM, alexo wrote:
> Copyright (C) 2015 Free Software Foundation, Inc.
> This is free software; see the source for copying conditions. There is NO
> warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
This is an old compiler.
 
Well, 2 years old, and that can be a long time when we get a new
standard every second year.
 
Essentially the maintenance of MinGW g++ has been passed from the
original MinGW project (where I believe you downloaded that compiler) to
the MinGW-64 project.
 
 
 
> main.cpp: In function 'void init_streams()':
> main.cpp:15:32: error: '_O_WTEXT' was not declared in this scope
> _setmode( _fileno( stdin), _O_WTEXT );
 
By inspection of the headers of that compiler's standard library, in
order to get a definition of `_O_WTEXT` with this compiler you need to
define `__MSVCRT_VERSION__` as equal or greater than `0x0800`.
 
Also, with `-std=c++11` option you need to explicitly tell it to not
define `__STRICT_ANSI__`, in order to get a definition of `_fileno`.
 
Which with this compiler's library is defined by the header that I
forgot to include, namely `<stdio.h>`.
 
It's weird that a compiler whose one and only purpose was to work in
Windows, doesn't. Anyway, the good news is that the newer g++ compilers
don't have these quirks. At least not the ones from MinGW-64.
 
Be that as it may, the following build command works for me, with g++
5.3.0-3 from the old MinGW project:
 
---------------------------------------------------------------------
[H:\forums\clc++\unicode in windows console]
> g++ --version
g++ (GCC) 5.3.0
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
 
[H:\forums\clc++\unicode in windows console]
> g++ _setmode.cpp -std=c++11 -D __MSVCRT_VERSION__=0x0800
-U__STRICT_ANSI__
 
[H:\forums\clc++\unicode in windows console]
> a
Every 日本国 кошка likes Norwegian blåbærsyltetøy!
 
What's your name? Særskrevne Påske Nøtter
Pleased to meet you, Særskrevne Påske Nøtter!
 
[H:\forums\clc++\unicode in windows console]
> _
---------------------------------------------------------------------
 
To avoid having to write all that every time, you can define the parts
that you'd otherwise have to repeat, as an environment variable.
 
Or, make a script or alias for the g++ invocation.
 
 
> main.cpp:28:14: error: converting to execution character set: Illegal
> byte sequence
> wcout << L"What's your name? ";
 
You just need to save your .cpp file with the encoding that g++ expects.
 
By default that's UTF-8.
 
And better make that UTF-8 with BOM, so that Visual C++ will understand
that it's UTF-8 by default.
 
 
> I've removed all C++11 flavours and I've added
 
> #include <cstdio>
 
> to turn off a couple of errors about finding stdin and stout.
 
Sorry about that, I plain forgot to include that header. :(
 
By the way it should be `<stdio.h>`.
 
The `<cstdio>` header may not necessarily provide unqualified names,
e.g. with that header one may have to write `std::stdin` instead of just
`stdin`.
 
 
> The problem is that my compiler cannot find _O_WTEXT
> and that it doesn't recognize the format L"..." string
 
 
Cheers & hth., :)
 
- Alf
alexo <alessandro.volturno@libero.it>: Apr 08 04:28PM +0200

>> warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
>> PURPOSE.
 
> This is an old compiler.
 
I'm sorry to have to agree to you. But I knew only the MinGW main
project site.
 
 
> Essentially the maintenance of MinGW g++ has been passed from the
> original MinGW project (where I believe you downloaded that compiler) to
> the MinGW-64 project.
 
Never heard of mingw-w64
 
 
 
> [H:\forums\clc++\unicode in windows console]
>> g++ _setmode.cpp -std=c++11 -D __MSVCRT_VERSION__=0x0800
> -U__STRICT_ANSI__
 
this is the output my actual (MinGW) g++ spits out:
 
g++: error: __MSVCRT_VERSION__=0x0800: No such file or directory
probably this is due to the compiler's old release number.
 
 
> To avoid having to write all that every time, you can define the parts
> that you'd otherwise have to repeat, as an environment variable.
 
> Or, make a script or alias for the g++ invocation.
 
I'm not sure the way it must be done.
Anyway the command history of the prompt shell helps a lot.
 
 
> By default that's UTF-8.
 
> And better make that UTF-8 with BOM, so that Visual C++ will understand
> that it's UTF-8 by default.
 
OK, encoded and saved using notepad++ text editor.
I didn't know of this encoding necessity.
 
Since UTF-8 is back-compatible to ASCII I'll use the former as the
default encoding format.
 
An off-topic question: could you brefly tell me what does the arrow mean
in the following main declaration?
 
 
thank you
 
auto main() -> int
{
...
}
"Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com>: Apr 08 06:39PM +0200

On 08-Apr-17 4:28 PM, alexo wrote:
> [snip]
> Never heard of mingw-w64
 
That wasn't quite what I wrote.
 
 
 
> this is the output my actual (MinGW) g++ spits out:
 
> g++: error: __MSVCRT_VERSION__=0x0800: No such file or directory
> probably this is due to the compiler's old release number.
 
You'd better copy and paste the command, and maybe edit the file name,
rather than typing it in.
 
Here it is again:
 
g++ your_file_name.cpp -std=c++11 -D __MSVCRT_VERSION__=0x0800
-U__STRICT_ANSI__
 
 
> An off-topic question: could you brefly tell me what does the arrow mean
> in the following main declaration?
 
> auto main() -> int
 
It means that `main` returns a function result of type `int`.
 
 
Cheers, & hth.,
 
- Alf
Mr Flibble <flibble@i42.co.uk>: Apr 08 11:44PM +0100

On 08/04/2017 15:28, alexo wrote:
 
> {
> ...
> }
 
It means that the person who wrote it has OCD.
 
/Flibble
fir <profesor.fir@gmail.com>: Apr 08 06:33AM -0700

in my roguelike game i wrote i made an option to say/shout
some predefined sentences to surroundings (then i can add switch to make near orcs angry if they will hear 'die dirty orc!'
or some things like this
 
but predefined sentences are bored and limited so i get idea
to predefine some number of words and allow player to compose
those words in some small language /in some sentences (this
has roguelike feel)
 
i need some small set of this words but making good and funny potential for shouts (i think i can assign one word to each 0-9 and a-z key on keyboard so it makes a dictionary of at most 36 predefined words and probably less at start)
 
what words could that be?
 
i only started to think on this, and some like
 
1- die
2- dirty
3- orc
4- you
5- nice
6- girl
7- ass
8 - I
9- will
0 - eat
a- your
b - elf
c - dwarf
 
(that would allow for example "you nice dirty orc" "die nice girl" "girl you orc" "I will eat your dirty ass dwarf"
and such kind 'climatic' experience ;c i need some inspiration
 
some ideas?
You received this digest because you're subscribed to updates for this group. You can change your settings on the group membership page.
To unsubscribe from this group and stop receiving emails from it send an email to comp.lang.c+++unsubscribe@googlegroups.com.

No comments: