Monday, January 23, 2017

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

"Rick C. Hodgin" <rick.c.hodgin@gmail.com>: Jan 23 06:05AM -0800

Can Jesus really help you and your family? Yes.
 
It's not just about salvation. That's the first step. For those who
are His, He then enters into their lives and guides them away from
tangles of sin, and into the ways which are of His Kingdom, right,
true, and holy. He will lead you out from where you are to where you
should be. He'll track with you through every misstep, every mistake,
and keep adjusting your path back to Him from wherever you are.
 
Watch this TV series, and see the 2010 movie of the same title, and
see by example how He affects hearts and minds:
 
The Encounter TV Series free trial on Pureflix:
https://www.facebook.com/PureFlix/videos/1482570295092910/
 
Thank you,
Rick C. Hodgin
Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk>: Jan 23 07:09PM

On 23/01/2017 14:05, Rick C. Hodgin wrote:
[Christian bullshit snipped]
 
Fuck. Off.
"Chris M. Thomasson" <invalid@invalid.invalid>: Jan 23 02:15PM -0800

On 1/23/2017 6:05 AM, Rick C. Hodgin wrote:
> see by example how He affects hearts and minds:
 
> The Encounter TV Series free trial on Pureflix:
> https://www.facebook.com/PureFlix/videos/1482570295092910/
 
Imvvoh, Jesus is very nice. satan had to be temping Him to think about
retaliating against those who were beating him mercilessly, for no
reason at all. Why hurt Jesus?
"Rick C. Hodgin" <rick.c.hodgin@gmail.com>: Jan 23 02:22PM -0800

On Monday, January 23, 2017 at 2:09:54 PM UTC-5, Mr Flibble wrote:
> ...
 
It's an alternate way of thinking and believing compared to the ways of
the world. But if you investigate it I think you'll find it's not only
a better way, it explain everything we see here in this world which is
hurtful and harmful. Jesus came to restore everything and turn it back
to what God intended before sin entered in and destroyed everything.
 
He cares about us (His creation), which is why He came here to save us,
and why He continues to seek to guide us in each of our daily lives.
He will .. if we'll let Him.
 
Thank you,
Rick C. Hodgin
Real Troll <real.troll@trolls.com>: Jan 23 06:45PM -0400

On 23/01/2017 22:15, Chris M. Thomasson wrote:
 
> Imvvoh, Jesus is very nice.
 
Don't be silly. there is no such thing as Jesus. That guy called Rick
Hodgin is hallucinating and he needs help - psychological.
David Brown <david.brown@hesbynett.no>: Jan 22 06:37PM +0100

On 21/01/17 19:51, Alf P. Steinbach wrote:
 
> That can work.
 
> It doesn't support turning on and off tracing within a translation unit,
> à la standard `assert`, but that seems to be the only limitation.
 
True.
 
> With standard `assert` the standard guarantees that you can change the
> macro definition by defining or undefining `NDEBUG` and re-including the
> `<assert.h>` header, so evidently some people have needed that.
 
Or at least, some people have /thought/ that some people have needed it!
 
legalize+jeeves@mail.xmission.com (Richard): Jan 23 07:07PM

[Please do not mail me a copy of your followup]
 
no@notvalid.com spake the secret code
 
>I hear experts all the time saying "dont use macros".
 
IMO, I believe the advice you're hearing has been truncated.
 
The advice I've seen has always been "don't use macros when there are
better alternatives".
 
The better alternatives are things that have been around for ages in
many cases:
 
- use enums for named integral constants
- use const values for named non-integral constants
- use inline functions for small bits of executable code
- use templates for code that varies by type
 
Things where macros are still unavoidable:
 
- turning a token into a string (preprocessor # operator)
- combining two tokens into a new token (preprocessor ## operator)
- include guards
 
Macros are still useful to eliminate large amounts of boiler plate:
 
- aggregate initializers where many values are repeated and only a few
differ
- common class boilerplate is required for derived classes
- tables of data that must be declared (e.g. wxBEGIN_EVENT_TABLE in
wxWidgets <http://docs.wxwidgets.org/3.0/overview_events.html>)
 
In this case, we're eliminating duplicate patterns of tokens that
can't be eliminated in other ways: inline functions, template
functions, etc. That's not to say that there isn't an alternative
design that avoids macros. For instance, some GUI toolkits express
event mechanisms by overriding virtual functions instead of declaring
tables mapping events to handlers.
--
"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>
Christian Gollwitzer <auriocus@gmx.de>: Jan 23 08:46PM +0100

Am 22.01.17 um 18:33 schrieb David Brown:
> assumption that it is so common that you expect people /do/ know what it
> is, and also that you have slashes for the options below, could it be
> Microsoft's C compiler?
 
Indeed it is. cl is the commandline version of the Visual C++ compiler,
Microsoft distributes free copies these days.
 
> It is not a tool I have ever used myself.
 
Blessed be. I had to fight with the infamous version 6.0 for a long
time. VC6.0 predates C++98, but it was for a long time the only compiler
that produces binaries without dependencies on Windows. All later
versions depend on a C++ runtime (a different one for each compiler
release), which must be installed on the user's machine - and this of
course requires admin priviledges. Therefore VC6 stuck around a lot...
with many ugly warts. The worst one is for variable scoping:
 
for (int i=0;...) { body; }
// here i is defined in VC6
 
Christian
Dombo <dombo@disposable.invalid>: Jan 23 10:06PM +0100

Op 23-Jan-17 om 20:46 schreef Christian Gollwitzer:
 
> for (int i=0;...) { body; }
> // here i is defined in VC6
 
> Christian
 
IIRC VC6 did have a compiler option to make the variable scoping
conforming, unfortunately this was not enabled by default.
"Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com>: Jan 23 11:19PM +0100

On 23.01.2017 20:46, Christian Gollwitzer wrote:
> with many ugly warts. The worst one is for variable scoping:
 
> for (int i=0;...) { body; }
> // here i is defined in VC6
 
For me one of the worst things about VC6 was that if you tried to do a
centralized exception translation thing (which at that time could be
useful e.g. for using IBM's Lotus Notes access library, and some
others), like this:
 
int main()
{
try
{
something();
return EXIT_SUCCESS;
}
catch( ... )
{
cerr << "!" << x_description() << endl;
}
return EXIT_FAILURE;
}
 
with `x_description` defined like
 
std::string x_description()
{
try
{
throw;
}
catch( std::exception const& x )
{
return x.what();
}
catch( Silly_IBM_integer_exception const x )
{
return blah( x );
}
catch( ... )
{
return "Unknown exception";
}
}
 
then you risked
 
• catching low-level SEH exceptions such as div-by-zero, and
 
• having a standard exception /destruced twice/.
 
It was ungood.
 
But DevStudio 6.0 was nice. :)
 
 
Cheers!,
 
- Alf
"Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com>: Jan 23 11:34PM +0100

On 23.01.2017 23:19, Alf P. Steinbach wrote:
> catch( std::exception const& x )
 
Oh sorry, I forgot that VC6 didn't even have standard exceptions. But
anyway.
 
 
- Alf
Dombo <dombo@disposable.invalid>: Jan 23 09:30PM +0100

Op 22-Dec-16 om 5:09 schreef Alf P. Steinbach:
 
> I've done this so many times in the past, with C++03. But I feel
> that there must be some less unclean modern C++-ish way. Ideas?
 
The question is what your main issue with the macros is. If you want to
avoid macros at all cost you could consider using variadic templates so
you can do something along the lines of:
 
class MyWindow
: public MessageDispatcher<WM_PAINT, WM_COMMAND, WM_DESTROY>
{
protected:
virtual void OnPaint() override
{
// ...
}
 
virtual bool OnCommand(WORD cmd, WORD evt, HWND hWndControl) override
{
// ...
}
 
virtual void OnDestroy() override
{
::PostQuitMessage(0);
}
 
// ...
};
 
 
Instead of using message cracker macro's you would have to provide
specialized template classes for every message to translate the message
into a virtual function call:
 
#include <windows.h>
 
template<UINT TMessage>
class MessageHandler;
 
template<>
class MessageHandler<WM_PAINT>
{
public:
LRESULT HandleMessage(HWND hWnd, UINT msg,
WPARAM wParam, LPARAM lParam)
{
OnPaint();
return 0;
}
 
virtual void OnPaint() = 0;
};
 
 
template<>
class MessageHandler<WM_COMMAND>
{
public:
LRESULT HandleMessage(HWND hWnd, UINT msg,
WPARAM wParam, LPARAM lParam)
{
return OnCommand(LOWORD(wParam), HIWORD(wParam),
reinterpret_cast<HWND>(lParam))
? 0
: ::DefWindowProc(hWnd, message, wParam, lParam);
}
 
virtual bool OnCommand(WORD commandId, WORD eventId,
HWND hWndControl) = 0;
};
 
 
template<>
class MessageHandler<WM_DESTROY>
{
public:
LRESULT HandleMessage(HWND hWnd, UINT message,
WPARAM wParam, LPARAM lParam)
{
OnDestroy();
return 0;
}
 
virtual void OnDestroy() = 0;
};
 
 
class MessageHandlerDefault
{
protected:
virtual LRESULT ProcessUnhandledMessage(HWND hWnd, UINT message,
WPARAM wParam,
LPARAM lParam)
{
return ::DefWindowProc(hWnd, message, wParam, lParam);
}
};
 
 
template<UINT ...TMessages>
class MessageDispatcher : protected virtual MessageHandlerDefault
{
protected:
LRESULT DispatchMessage(HWND hWnd, UINT message, WPARAM wParam,
LPARAM lParam)
{
return ProcessUnhandledMessage(hWnd, message, wParam, lParam);
}
};
 
 
template<UINT TMessage, UINT ...TMessages>
class MessageDispatcher<TMessage, TMessages...>
: protected MessageDispatcher<TMessages...>
, protected virtual MessageHandler<TMessage>
{
public:
LRESULT DispatchMessage(HWND hWnd, UINT message,
WPARAM wParam, LPARAM lParam)
{
return message == TMessage
? MessageHandler<TMessage>::HandleMessage(hWnd, message,
wParam, lParam)
: MessageDispatcher<TMessages...>::DispatchMessage(hWnd,
message,
wParam,
lParam);
}
};
 
 
As much as I dislike macros I doubt that the above hack is better than
just accept that macros are sometimes the way to go.
Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk>: Jan 23 10:34PM

On 23/01/2017 20:30, Dombo wrote:
[horrid Windows code snipped]
 
> As much as I dislike macros I doubt that the above hack is better than
> just accept that macros are sometimes the way to go.
 
Yes there is: use a portable widget toolkit. The least worst one at the
moment is Qt but I am working on changing that with neoGFX:
 
http://neogfx.org/
 
Coming soon!
 
/Flibble
"Christopher J. Pisz" <cpisz@austin.rr.com>: Jan 23 04:16PM -0600

phone screen today asked about hastables, what they are, how they work, etc.
 
I answered a kind of "well I have never had to really create one from
scratch in C++, I just use the built in data structures like map if I
want an associative container"
 
I know there is a hash that is defined by some has function on some but
of data, that provides fast lookup...
 
I told them that I was under the impression that map used a hash table
under the hood, and then blabbed about it being related to a
tree..failsauce.
 
so, std::map is implemented as a tree and std::unordered_map is
implemented as a hastable?
 
What are the differences, advantages, etc?
fl <rxjwg98@gmail.com>: Jan 23 12:13PM -0800

Hi,
 
I am learning GSL library on my Ubuntu 16.04LTS computer. GSL is successfully
installed. It can build a simple .cpp file:
 
g++ main.cpp -L/home/jeff/gsl/lib -I/home/jeff/gsl/include -lgsl -lgslcblas -lm
 
 
That is, GSL is installed on directory:
/home/jeff/gsl
 
 
 
 
 
Now, I download a tutorial project, which needs to build the library first.
It instructs to run:
 
make library
 
on a command line under the top tutorial directory.
 
 
The tutorial does say the Makefile needs to modify for GSL library, but
I don't know how to do it after several trials.
 
Below is the head Makefile under the tutorial directory:
 
 
--top directory, Makefile:
 
.PHONY: docs clean distclean examples
 
default: libraries examples
 
all: libraries docs examples
 
clean:
make -Csrc clean
make -Cexamples clean
-rm *~
-rm */*~
 
distclean: clean
-rm bin/*
-rm lib/*
-rm -Rf doc/*
 
libraries:
make -Csrc all
....
 
This is the Makefile under top/src/ directory:
 
 
 
--src directory Makefile:
 
include ../Makefile.in
 
SMCC = rng.cc history.cc smc-exception.cc
SMCO = rng.o history.o smc-exception.o
 
all: libsmctc.a
 
.PHONY: clean
 
clean:
-rm *.o
-rm *.a
-rm *~
 
libsmctc.a: $(SMCC) Makefile
$(CC) $(CCFLAGS) -c -I../include $(SMCC)
ar rcs libsmctc.a $(SMCO)
cp libsmctc.a ../lib
/////////////////
 
When I run my modified Makefile, it gives such errors:
 
$ make libraries
make -Csrc all
make[1]: Entering directory '/home/jeff/workspace/smctc-1.0/src'
g++ -O3 rng.cc history.cc smc-exception.cc
rng.cc:7:18: fatal error: rng.hh: No such file or directory
compilation terminated.
history.cc:1:20: fatal error: smctc.hh: No such file or directory
compilation terminated.
smc-exception.cc:1:28: fatal error: smc-exception.hh: No such file or directory
 
 
 
Anyhow, I cannot figure out the right way to modify Makefile.
Can you help me out?
 
 
Thanks.
fl <rxjwg98@gmail.com>: Jan 23 01:09PM -0800

On Monday, January 23, 2017 at 3:13:24 PM UTC-5, fl wrote:
 
> Anyhow, I cannot figure out the right way to modify Makefile.
> Can you help me out?
 
> Thanks.
 
In fact, I've been learning makefile a few times. Now the makefiles in Ubuntu
are more involved, for it having a subdirectory makefile.
 
In the following snippet, I know libsmctc.a is a make target.
But '$(SMCC) Makefile' is puzzling. $(SMCC) is like a parameter to put into
Makefile?
 
Second, $(CC) and $(CCFLAGS) have default values in the Makefile?
Thanks again.
 
-----------------
SMCC = rng.cc history.cc smc-exception.cc
SMCO = rng.o history.o smc-exception.o
 
...
 
libsmctc.a: $(SMCC) Makefile
$(CC) $(CCFLAGS) -c -I../include $(SMCC)
ar rcs libsmctc.a $(SMCO)
cp libsmctc.a ../lib
Riccardo Zanella <riiccardo.zanella_RE_MOVE@gmail.com>: Jan 23 10:13PM +0100

Il 23/01/17 21:13, fl ha scritto:
> smc-exception.cc:1:28: fatal error: smc-exception.hh: No such file or directory
 
> Anyhow, I cannot figure out the right way to modify Makefile.
> Can you help me out?
 
(I suppose you are compiling https://github.com/matsengrp/smctc)
 
Seems that compilation command for libsmctc.a target can't find rng.hh
(and smctc.hh and smc-exceptions.hh). Such include files are not GSL,
and should be in include (-I../include was meant to find those files).
 
For GSL:
change Makefile.in by adding:
-I path_to_gsl_includes to CCFLAGS
-L path_to_gsl_libs in LFLAGS just before -lgsl
 
Riccardo
Jorgen Grahn <grahn+nntp@snipabacken.se>: Jan 23 10:01PM

On Mon, 2017-01-23, fl wrote:
> On Monday, January 23, 2017 at 3:13:24 PM UTC-5, fl wrote:
>> Hi,
...
 
> In the following snippet, I know libsmctc.a is a make target.
> But '$(SMCC) Makefile' is puzzling. $(SMCC) is like a parameter to put into
> Makefile?
 
You mean
 
libsmctc.a: $(SMCC) Makefile
 
Have you tried reading the Make manual? $(SMCC) is variable expansion,
much like C++ macros. So that's the same thing as
 
libsmctc.a: rng.cc history.cc smc-exception.cc Makefile
 
That looks like a really badly-written Makefile. A static library
should simply depend on the object files you want to put into it:
 
libsmctc.a: rng.o history.o smc-exception.o
$(AR) rcs $@ $^
 
> Second, $(CC) and $(CCFLAGS) have default values in the Makefile?
 
Gnu Make (which you're using, since you're on Linux) predefines some
names. But something is a bit off here:
 
- $(CC) is the name of the C compiler; the C++ compiler is called $(CXX).
- $(CCFLAGS) looks like one of the predefined names, but the C compiler
options are called $(CFLAGS) and the C++ ones $(CXXFLAGS).
 
A Makefile can use any names it wants, but not choosing the standard
names certainly makes things harder.
 
> $(CC) $(CCFLAGS) -c -I../include $(SMCC)
> ar rcs libsmctc.a $(SMCO)
> cp libsmctc.a ../lib
 
/Jorgen
 
--
// Jorgen Grahn <grahn@ Oo o. . .
\X/ snipabacken.se> O o .
Chris Vine <chris@cvine--nospam--.freeserve.co.uk>: Jan 23 03:17PM

On Sun, 22 Jan 2017 19:55:57 -0300
> Maybe someone "can recognize" a direct (and accurate) reference to
> this newsgroup:
 
> http://www.theregister.co.uk/2017/01/20/cerity_has_7_h8s/
 
That's a good find on your part, and pretty accurate, I would say.
 
The basic problem is that open access newsgroups make it too easy for
those who are mentally ill or have other personality issues to ease
their pains by inflicting them on others instead. It does seem to have
got a lot worse in the last 6 months though. We have the poster who
seems clearly mentally ill with his "Please read again" postings of
corrections of corrections of corrections of things that no one was
interested in in the first place. And we have our two religious
nutjobs who are unable to respect others, or grasp that if everyone
used this newsgroup for proselytising their favorite brand of religion
it would be turned into an unbearable ocean of shit rather than the
current (only cesspit sized) pile of turd, and at least one of whom is
also dim and suffers from the delusion that he should be "leading" C++
(whatever that may mean).
 
And we now also seem to have acquired this Jeff guy who cross-posts
random garbage to this newsgroup in classic troll mode. And we have a
different poster (strangely silent for the last 4 or so weeks) who will
join any argument which he doesn't understand and take it to the point
of absurdity, cannot bear not to have the last word and doesn't mind
projecting himself as a complete dickhead.
 
I used to think that this newsgroup had enough sensible on topic
posting about C++ to survive all this. Now I am not so sure.
 
But I guess some things can still get better. Some may remember the
"plink" days. That particular individual seems to have completely
reformed.
"Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com>: Jan 23 05:58PM +0100

On 22.01.2017 23:55, Cholo Lennon wrote:
> Maybe someone "can recognize" a direct (and accurate) reference to this
> newsgroup:
 
> http://www.theregister.co.uk/2017/01/20/cerity_has_7_h8s/
 
It's weird that Verity doesn't mention ¹Reddit, or ²Facebook.
 
I think with her main focus on the working programmer's plight it's
understandable that she doesn't mention in passing the ³death of
comp.std.c++, and later of comp.lang.c++.moderated, and the impact of
that on the standardization process, and thus, on the language itself.
 
But I would have expected her to mention Reddit. Weird. Even though I'm
not using Reddit myself, other than the occasional glance. :)
 
 
Cheers!,
 
- Alf
 
Notes:
¹ E.g. <url: https://www.reddit.com/r/cpp/>
² E.g. <url: https://www.facebook.com/groups/cppEnthusiasts/>. This is a
popular Facebook group started by Prasoon Saurav and mostly moderated by
Matt P. Dziubinski and me; Matt provides a steady stream of interesting
news, for which the only possible explanation is − that he skims it off
the alligator aliens' Earth surveillance records!
³ With the first death of comp.std.c++ I argued, to its moderators and
to my co-moderators of comp.lang.c++.moderated, that it should be
rescued. It got up and running again using the clc++m infra-structure.
The last new thread I see was started by Ian Collins, dated january 2016
and approved by Matt Austern.
https://groups.google.com/forum/#!original/comp.std.c++/RqKItgcFLiw/7jz22gIYBgAJ
"Öö Tiib" <ootiib@hot.ee>: Jan 22 11:37PM -0800

On Monday, 23 January 2017 00:44:24 UTC+2, Mike Copeland wrote:
> Is there a simple and efficient way to read and store data that looks
> like the following?
 
> 123a2345a34b812a2467c1717b2626c2983b3291a8a14c28c
 
Who knows. It looks like binary data in hexadecimal representation
of bytes however there is curious single c at end.
 
12 3a 23 45 a3 4b 81 2a 24 67 c1 71 7b 26 26 c2 98 3b 32 91
a8 a1 4c 28 c
 
If it is that then it is among most trivial things.
 
> there a technique (such as the "for (int num; ss >> num;)" technique
> with an istringstream) that can process a variable number of such data
> sets as I have described? TIA
 
Your description of it sounds way different than what you example
looks like.
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: