Sunday, July 14, 2019

Digest for comp.lang.c++@googlegroups.com - 17 updates in 8 topics

Nikki Locke <nikki@trumphurst.com>: Jul 14 10:23PM

Available C++ Libraries FAQ
 
URL: http://www.trumphurst.com/cpplibs/
 
This is a searchable list of libraries and utilities (both free
and commercial) available to C++ programmers.
 
If you know of a library which is not in the list, why not fill
in the form at http://www.trumphurst.com/cpplibs/cppsub.php
 
Maintainer: Nikki Locke - if you wish to contact me, please use the form on the website.
"Heinz Müller" <Heinz.Mueller69@gmail.com>: Jul 14 11:16AM +0200

Your code is wonderful! Everyone should code like that!
ram@zedat.fu-berlin.de (Stefan Ram): Jul 14 08:56AM

>I suggest you just put a call of it in a conditional where it's
>guaranteed not executed.
 
FWIW: The GNU ::std::thread implementation seems to include
code the effect of which is similar to
 
decltype
( ::std::__invoke
( ::std::forward< _Callable >( __f ),
::std::forward< _Args >( __args )... ))
 
, where ::std::__invoke is a GNU extension (header <invoke.h>).
 
The type of ::std::__invoke is declared using
__invoke_result, which is defined in <type_traits>.
 
This, then, eventually detects the mismatch of the argument
list types with a failure to define a member "type". (I have
not understood all details of how this works.)
 
main.cpp
 
#include <initializer_list>
#include <string>
#include <thread>
 
using namespace ::std::literals;
 
void f( int ){}
 
int main() { ::std::thread{ f, ""s }; }
 
abbreviated transcript
 
error: no type named 'type' in 'struct
std::__invoke_result<void (*)(int),
std::__cxx11::basic_string<char, std::char_traits<char>,
std::allocator<char> > >'
Szyk Cech <szykcech@spoko.pl>: Jul 07 01:39PM +0200

W dniu 07.07.2019 o 12:28, Juha Nieminen pisze:
 
> Any style guide that *recommends* "using namespace std;" is immediately
> suspect (especially if it says "usning".)
 
Spieling fixed!
 
But why it "is immediately suspect" - what is wrong to use in *.cpp such
clause - if you don't have any conflicted code.
Use this clause in *.h can potentially broke your code, but in *.cpp
this usage looks safe.
 
> And why exactly 77, and
> not for example 78, or 76? What's so special about 77 in particular?
 
This is due to language sybolics. People differ from animals in many
ways. One of them is they should put importance about right symbolics.
This can be real (and controled) blesing.
 
One of most common sybolics is pseudo translation words from one meaning
to another. I show you this in your language:
Lets say we have name like: "Area 51". What aliens so much likes its
symbolics? I can tell you: This is translated to: "Area fifty (for)
one". Great deal! - isn't it?!?
The same is about "80 characters per line" in Polish translated means
some thing like this: "moose dozens fixed in line". And in Poland we
talk somebody is "moose" when we think it is not very cleaver or even is
stupid. "77 characters per line" in Polish means some thing like this:
"self dozens self fix in line" - and I suppose it means that with this
you will make your self stronger dozens times.
 
Symbolics is something does not work immediately, but after some time,
just like Karma algorithms (in true Greyer the sybolic executor can
write artifical algorithm to human Karma which is set of future
feelings). More about Karma here: http://totalizm.pl/karma.htm
Note about Karma explorer (prof. Jan Pająk): he was unaware that every
human has its own supervisor who patiently watch and judge your every
move. You can prove this to your self if you will notice when you
sneeze, sight, or cough (in the cases you are not sick). All of such
behaviour is artificial and connected with current your thought or speak
(typically when you think or talk nonsense). There are many more
evidences of such supervisors - stay tuned - then you will notice them.
 
So do you still think it is stupid? If so you must also claim you are
smarter than hyper-intelligent Greys which puts great attention to
execute sybolics made by humans.
 
> I don't even understand what "No use private clause in function
> declaration" is supposed to mean.
 
Fixed!
 
 
Thank for your reply. You help improve my "C++ coding style" page.
best regards
Szyk Cech
Szyk Cech <szykcech@spoko.pl>: Jul 07 04:53PM +0200

W dniu 07.07.2019 o 12:28, Juha Nieminen pisze:
> This both is too simplistic, and at the same time goes too much into
> nitpicking useless advice.
 
So:
1. Code with bad style does not exists?
2. Did you suppose programming manual instead "Coding style
recommendations"?
Juha Nieminen <nospam@thanks.invalid>: Jul 07 10:28AM

> http://szyk.jcom.pl/stylkodu.html
 
This both is too simplistic, and at the same time goes too much into
nitpicking useless advice.
 
Any style guide that *recommends* "using namespace std;" is immediately
suspect (especially if it says "usning".)
 
Also any style guide that recommends things that the standard libraries
don't do is also suspect, such as demanding that all destructors be
virtual. (Basically no class in the standard library that has a
destructor has a virtual destructor, with only some exceptions.)
 
Limiting line length to 77 characters has been obsolete for decades.
There's nothing special about the number 80 in this respect in the
modern world, and hasn't been for decades. (And why exactly 77, and
not for example 78, or 76? What's so special about 77 in particular?)
 
I don't even understand what "No use private clause in function
declaration" is supposed to mean.
"Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com>: Jul 08 10:58PM +0200

On 08.07.2019 22:16, Vir Campestris wrote:
>> Limiting line length to 77 characters has been obsolete for decades.
 
> We've got that in our newly introduced standard. Apparently it came from
> Google.
 
Some people noticed when Google dispensed with the "do no evil", and
wrote about it, but I think not more than a handful.
 
Corporate structures and bureaucracies are like that.
 
Mindless submission to arbitrary, outdated, often counter-productive rules.
 
My pet hypothesis is that the effect of knowledge is so strong and
positive that even when 95% of what one believes is bullshit, the 5%
mostly correct stuff more than makes up for the negative effects of the
rest.
 
So, these human organizations get by.
 
 
Cheers!,
 
- Alf
Szyk Cech <szykcech@spoko.pl>: Jul 07 06:20PM +0200

W dniu 07.07.2019 o 17:34, Manfred pisze:
> declared private. In particular, declaring data members protected is
> usually a design error."
> Which is exactly what you are recommending here...
 
Ok. I can explain why I hate private functions and private variables and
not virtual destructors:
 
I use Qt library for long time (10 years), before I program in C++
Builder for 10 years.
Over the years many times I try to do things not imagined by library
creators (Qt, VCL and others). I hate them much, because some times
they limited me from innovations in the way my apps work.
 
For example: I want to write user emulation tests - by emulate user
behaviour like mouse clicking and keyboard pressing, and I want to
emulate menu clicking by using standard function calls (not automated
mouse clicking because I can't be sure where is menu on the screen). But
I can't do it due to lack such functions exposed by QMenu. People makes
funny and very complicated solutions to this problem, but I want do it
in Qt way (mean: easy). The same problem cause I can't properly
show/hide menu when right alt is pressing - because I can't control menu
focus.
In this case subclass does nothing because Qt use other "modern trick":
it use internal object under private pointer called "d" (like data) with
not defined type. And this internal class stores all internals of the Qt
class. Most Qt classes are programmed in this way.
 
My last problem was: Qt does not use exceptions, but I want use them to
make sensible error handling. So I want to write my own Query class
subclass of QSqlQuery. But it is impossible due to non virtual
destructor in QSqlQuery (it will not close database connection when I
delete it).
 
I think this is not user friendly because library vendor have no
problems when you extend class in your way. I don't think library
vendors know better than user what is good for him/her.
 
best regards
Szyk Cech
Melzzzzz <Melzzzzz@zzzzz.com>: Jul 11 12:29AM


> Yes Qt is currently the *least worst* offering as far as a cross platform
> C++ GUI library is concerned but I intend to improve on that sorry state
> of affairs with neoGFX.
 
Cross platform is not in interrest of M$ and Apple$...
 
--
press any key to continue or any other to quit...
U ničemu ja ne uživam kao u svom statusu INVALIDA -- Zli Zec
Na divljem zapadu i nije bilo tako puno nasilja, upravo zato jer su svi
bili naoruzani. -- Mladen Gogala
Szyk Cech <szykcech@spoko.pl>: Jul 11 05:57AM +0200

W dniu 11.07.2019 o 00:05, Öö Tiib pisze:
> Usage of GUI scripting with QML is not anyhow forced by it.
 
Why do you tell this? I wrote that they force to use QML in mobile apps.
If you want write mobile apps in C++ then you will see many difficulties:
* widgets not prepared for finger (small controls) - QML styled widgets
are not exposed to C++ - you will have to create your own styles for
widgets for mobile apps.
* some widgets behaviour present in QML is not exposed to C++. I talk
about animations in GUI.
 
p8mode wants to use QtQuick without QML and talk about this years ago on
official Qt forum:
https://forum.qt.io/topic/20843/qtquick-without-qml-pure-c-apps-possible/4
 
The answer was:
"While passions run high on this issue and there are good points to be
made by all parties involved, the short answer is that a QML-less Qt
Quick is not on the immediate Qt roadmap."
 
Up to now seems they change nothing in their minds.
Keith Thompson <kst-u@mib.org>: Jul 10 01:08PM -0700

James Kuyper <jameskuyper@alumni.caltech.edu> writes:
[...]
> indeed the compiler that is required to recognize the start point, but
> it's the linker that actually does what's needed to make the program
> start there.
 
I don't believe the compiler is required to recognize the entry point.
Under gcc, for example, it appears to be just another function.
 
When I compile these two functions:
int main(void) { return 0; }
and
int notmain(void) { return 0; }
 
with "gcc -S", the assembly listings are identical other than
the function name. It's the linker that recognizes "main" as the
entry point.
 
The compiler does recognize "main" so it can generate code
equivalent to "return 0;" if control reaches the closing "}";
I deliberately avoided that in my examples. But a conforming
compiler could just do that for all int functions.
 
--
Keith Thompson (The_Other_Keith) kst-u@mib.org <http://www.ghoti.net/~kst>
Will write code for food.
void Void(void) { Void(); } /* The recursive call of the void */
Juha Nieminen <nospam@thanks.invalid>: Jul 10 09:53PM


>> or is it somehow set in the compiler the name of the function
>> where to start?
 
> On gcc, you can use the "--entry" option.
 
You can also use -nostartfiles, which gives you a much more
barebones executable. Rather than main(), a function with the
signature void _start() (no parameters) will be called at
startup. (The proper way to end the program in this situation
is to call exit(). I'm not sure what happens if the _start()
function just ends. Maybe it crashes or something.)
 
You'll have a much harder time getting any command-line
parameters, but in many programs they aren't actually needed.
James Kuyper <jameskuyper@alumni.caltech.edu>: Jul 10 02:52PM -0400

On 7/10/19 2:24 PM, G G wrote:
> is it possible that c/c++ programs can start with something other
> than a function named main()?
 
Since you're explicitly asking about both C and C++, I'm cross-posting
this to comp.lang.c.
 
Yes it is possible, but only for freestanding implementations:
 
"In a freestanding environment (in which C program execution may take
place without any benefit of an operating system), the name and type of
the function called at program startup are implementation-defined." (C
standard, 5.1.2p1)
 
"It is implementation-defined whether a program in a freestanding
environment is required to define a main function." (C++ standard, 6.6.1p1).
 
> or is it somehow set in the compiler the name of the function
> where to start?
 
An implementation of C or C++ can conform either as a freestanding
implementation or a hosted one. A hosted implementation must recognize
main() as the starting point. A freestanding implementation may have
other ways of identifying the starting point, but is required to
document them, and (implicitly) is required to conform to whatever
documentation it provides. Either way, it is indeed up to the
implementation to recognize the permitted ways of identifying the
starting point of a program.
 
It is common, but not essential, for an implementation to be divided
into several separate parts, such as a pre-processor, a compiler, and a
linker. However, the standard says nothing about how the work of an
implementation should be sub-divided. It is only the implementation as a
whole that has responsibility for implementing the correct start point
for a program.
That being said, in a typical pre-processor/compiler/linker setup, it is
indeed the compiler that is required to recognize the start point, but
it's the linker that actually does what's needed to make the program
start there.
David Brown <david.brown@hesbynett.no>: Jul 11 09:31AM +0200

On 10/07/2019 23:53, Juha Nieminen wrote:
> function just ends. Maybe it crashes or something.)
 
> You'll have a much harder time getting any command-line
> parameters, but in many programs they aren't actually needed.
 
You usually use this sort of thing in very small systems embedded
programming. You don't have a command line, much less command-line
parameters, and your _start() function never ends because you invariably
have an infinite loop in your main code.
 
I have only once needed --nostartfiles, for programming a
microcontroller with no ram at all. It had 32 8-bit cpu registers, and
a three level hardware call stack. Having _start() call main() would
have wasted at least a third of the resources of the cpu!
legalize+jeeves@mail.xmission.com (Richard): Jul 10 04:51PM

[Please do not mail me a copy of your followup]
 
gazelle@shell.xmission.com (Kenny McCormack) spake the secret code
>>time ago - the first C standard is 30 years old - older than many
>>(most?) of the people writing C code.
 
>I seriously doubt that. Aren't more C programmers old farts like us?
 
It depends on the application market segment. While it was routine to
write everything in C/C++ from the 80s and into the 90s, other
languages have arrived on the scene that have found their niche. Java
is dominant in enterprise level applications (with exceptions such as
financial trading) where people hate MS, C# is dominant in MS
enterprise applications or for Windows desktop applications (with
exceptions such as 3D and gaming), Ruby and Python are popular in Web
CRUD applications, etc.
 
>Most recruiters these days consider C++ "legacy". C is essentially in the
>same category as Cobol.
 
Most recruiters don't know their ass from a hole in the ground. C/C++
is dominant in the embedded space and not much manages to displace it
except for CPU specific assembly language and even there, most people
only use assembly for small sections of the overall system.
--
"The Direct3D Graphics Pipeline" free book <http://tinyurl.com/d3d-pipeline>
The Terminals Wiki <http://terminals-wiki.org>
The Computer Graphics Museum <http://computergraphicsmuseum.org>
Legalize Adulthood! (my blog) <http://legalizeadulthood.wordpress.com>
Martijn van Buul <pino@dohd.org>: Jul 08 10:15AM

* James Kuyper:
 
> being a significant issue for most developers a long time ago - the first C
> standard is 30 years old - older than many (most?) of the people writing C
> code.
 
Minix would be the counter argument there: There is a lot of legacy code
in Minix. While Minix 3 isn't a spring chicken anymore, there is a lot
of legacy from Minix 2 around, which harks from a time when this was
very much an issue. I've dabbled with Minix quite a bit in my youth (fond
memories there), and there was a generous portion of K&R C floating around in
there.
 
Not that I would advocate Minix to be the golden standard for C coding,
nor do I think that it's particularly on-topic here. While the "Operating
System, Design and Implementation" books are still somewhat relevant, they
were never intended as a textbook on *programming*.
 
--
Martijn van Buul - pino@dohd.org
Szyk Cech <szykcech@spoko.pl>: Jul 07 12:46PM +0200

Hi!
On the page:
http://think-async.com/Asio/asio-1.12.2/doc/asio/overview/serial_ports.html
There is sentence wchis is pure nonsense to me:
 
"For Windows, serial ports are only available at compile time when the
I/O completion port backend is used"
 
What does it mean? For Windows serial port is available when program is
compiling? How can it be run when it is not fully compiled?
I never heard about such conception!
 
Please explain this to me.
 
thanks in advance
and best regards
Szyk Cech
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: