|
|
I can't find the thread where clipka pointed out to me that the leading
underscore is a reserved macro. This has been my style since before
those punks at std were playing their daddy's Atari.
Well, the latest version of Qt turns on a shitload of warnings. One of
which is "Use of reserved macro name". baf.
Another one is sign coercion, i.e. use of unsigned int for an int.
I would be happier if Qt had added unsigned overloads, like resizing a
window, as if I could make a window -10 pixels wide.
Oh, ok...
quint32 h = 10, w = 10;
window.resize( (int)h, (int)w );
*Now* I get a warning "use of old style conversion".
Well yeah, I'm old. Shut up. Either remove the feature or shutup. :)
--
dik
Rendered 328976 of 330000 (99%)
Post a reply to this message
|
|
|
|
Am 07.08.2018 um 04:01 schrieb dick balaska:
> I can't find the thread where clipka pointed out to me that the leading
> underscore is a reserved macro. This has been my style since before
> those punks at std were playing their daddy's Atari.
I can repeat it if that helps ;)
In the C++11 standard, the corresponding rules can be found in section
17.6.4.3.2, "Global names".
If you don't have access to a copy of the C++11 standard, I can
recommend this website, which according to my experience sums up the
actual standard pretty faithfully and precisely (and is also very
helpful to figure out in which version of C++ a particular feature is
available):
https://en.cppreference.com/w/cpp/language/identifiers
If it soothes your pain a bit, POV-Ray v3.7.0 also wrongfully used a few
reserved names.
> Well, the latest version of Qt turns on a shitload of warnings. One of
> which is "Use of reserved macro name". baf.
And rightfully it does: Using any reserved identifier for your own
purposes leads to "undefined behaviour" - meaning your compiled program
could do anything, even cause the Higgs field to spontaneously decay to
a lower potential and thereby wipe out the entire universe. We don't
want that to happen.
> Another one is sign coercion, i.e. use of unsigned int for an int.
> I would be happier if Qt had added unsigned overloads, like resizing a
> window, as if I could make a window -10 pixels wide.
>
> Oh, ok...
>
> quint32 h = 10, w = 10;
> window.resize( (int)h, (int)w );
>
> *Now* I get a warning "use of old style conversion".
That's a more petty warning, because the program is technically well-formed.
To avoid the warning, try
window.resize( int(h), int(w) );
which by definition does exactly the same, but is considered C++ (as
opposed to C) style. The drawback is that the type must be a single
word, e.g. `signed int(h)` won't work.
Even better, because less ambiguous (especially when casting non-trivial
types):
window.resize( static_cast<int>(h), static_cast<int>(w) );
Of course the drawback is that it's more to type (or read, for that matter).
Post a reply to this message
|
|