Thursday, March 23, 2017

Digest for comp.lang.c++@googlegroups.com - 19 updates in 5 topics

"Tristan B. Kildaire" <deavmi@disroot.org>: Mar 23 06:23PM +0200

General question.
 
A static library is one in which the library's code is put into the
program's source file and then compiled into a "monolith" executable.
 
A dynamic library is one that is not included in the program's source
code (as in the library's code is not included) but it is loaded during
some time in the program's execution.
"Rick C. Hodgin" <rick.c.hodgin@gmail.com>: Mar 23 09:35AM -0700

On Thursday, March 23, 2017 at 12:23:28 PM UTC-4, Tristan B. Kildaire wrote:
 
> A dynamic library is one that is not included in the program's source
> code (as in the library's code is not included) but it is loaded during
> some time in the program's execution.
 
Was that a question?
 
Your statement is correct. Static libraries have benefits in that
the code will always work the way it went out. Dynamic libraries
have benefits in that they can receive security and bug fixes without
affecting the original program, or requiring updates or re-installation
of the original program, but could potentially break when new updates
are sent out which alter the expected behavior, introducing bugs which
are essentially external to your core app.
 
Static libraries can also receive some special optimizations dynamic
libraries cannot, because the linker can perform fixups which allow
for the optimizations.
 
Thank you,
Rick C. Hodgin
"Rick C. Hodgin" <rick.c.hodgin@gmail.com>: Mar 23 09:39AM -0700

On Thursday, March 23, 2017 at 12:23:28 PM UTC-4, Tristan B. Kildaire wrote:
 
> A dynamic library is one that is not included in the program's source
> code (as in the library's code is not included) but it is loaded during
> some time in the program's execution.
 
Bear in mind also that the "source file" you're referring to here is not
source code. Static libraries typically come from .lib files, which are
symbolic binary files. They contain information for the linker, and not
information for the source code compiler.
 
Thank you,
Rick C. Hodgin
Barry Schwarz <schwarzb@dqel.com>: Mar 23 09:41AM -0700

On Thu, 23 Mar 2017 18:23:02 +0200, "Tristan B. Kildaire"
 
>General question.
 
>A static library is one in which the library's code is put into the
>program's source file and then compiled into a "monolith" executable.
 
A static library does not have source code. It has object modules.
They are linked with the programs object modules into a monolithic
executable which is not affected by any subsequent changes to the
library.
 
>A dynamic library is one that is not included in the program's source
>code (as in the library's code is not included) but it is loaded during
>some time in the program's execution.
 
The object modules of a dynamic library remain separate from the
programs executable and are loaded only during execution as required.
If a dynamic library changes between executions, the later executions
receive the updated versions of the modules.
 
--
Remove del for email
scott@slp53.sl.home (Scott Lurndal): Mar 23 04:49PM

>General question.
 
>A static library is one in which the library's code is put into the
>program's source file and then compiled into a "monolith" executable.
 
No, a static library is linked with the program's object code
to create a monolith executable.
 
 
>A dynamic library is one that is not included in the program's source
>code (as in the library's code is not included) but it is loaded during
>some time in the program's execution.
 
A dynamic library is associated with the programs object code, but not
linked to it until the program is executed.
Christopher Pisz <christopherpisz@gmail.com>: Mar 23 12:10PM -0700

On Thursday, March 23, 2017 at 11:23:28 AM UTC-5, Tristan B. Kildaire wrote:
 
> A dynamic library is one that is not included in the program's source
> code (as in the library's code is not included) but it is loaded during
> some time in the program's execution.
 
The answer is obviously 17.
Christian Gollwitzer <auriocus@gmx.de>: Mar 23 09:07PM +0100

Am 23.03.17 um 17:41 schrieb Barry Schwarz:
> They are linked with the programs object modules into a monolithic
> executable which is not affected by any subsequent changes to the
> library.
 
Maybe it could be mentioned that there is a third kind of a library
especially in the C++ case, the template library, where indeed the
source code is more-or-less copied into the program source. Usually the
program contains in #include for library files from Boos or from the
STL, which is performed by textually inserting the content of the
included file in the source code of the program. A few C libraries also
exist which work in a similar way (using static functions), but this is
mre controversial because for non-template functions this is not necessary.
 
Christian
Vir Campestris <vir.campestris@invalid.invalid>: Mar 23 09:51PM

On 23/03/2017 19:10, Christopher Pisz wrote:
 
>> A dynamic library is one that is not included in the program's source
>> code (as in the library's code is not included) but it is loaded during
>> some time in the program's execution.
 
Frequently it is loaded before the execution starts. The program header
contains references to libraries that must be loaded, and they in turn
contain references to other libraries.
It's actually unusual in my experience for a program to explicitly load
a dynamic library.
 
 
> The answer is obviously 17.
 
42, surely?
 
What was the original question?
 
Andy
legalize+jeeves@mail.xmission.com (Richard): Mar 23 09:55PM

[Please do not mail me a copy of your followup]
 
"Tristan B. Kildaire" <deavmi@disroot.org> spake the secret code
 
>A dynamic library is one that is not included in the program's source
>code (as in the library's code is not included) but it is loaded during
>some time in the program's execution.
 
This may help:
<https://www.slideshare.net/LegalizeAdulthood/consuming-and-creating-libraries-in-c>
--
"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>
Christopher Pisz <christopherpisz@gmail.com>: Mar 23 08:50AM -0700

I don't think there is any cancel mechanism, only signal. So, what do I do in the following scenario (I try to describe best I can)?
 
There is a blocking call in existing code that expects a value to be returned for a given string.
 
There is an asynchronous networked library that can get that value for the given string.
 
So, I created a condition variable in the former that gets signaled when a map is updated in the latter.
 
Problem is if I get disconnected while waiting, I don't want the calling thread to wait forever and the request for the data over the network has already fired so it is gone.
 
I think I have to implement some kind of reconnect mechanism, signal the condition variable and then not only see if the string is on the map, but also whether or not we are connected. I'm not sure.
 
What tools do I have in my tool box for this scenario?
Paavo Helde <myfirstname@osa.pri.ee>: Mar 23 06:42PM +0200

On 23.03.2017 17:50, Christopher Pisz wrote:
 
> Problem is if I get disconnected while waiting, I don't want the calling thread to wait forever and the request for the data over the network has already fired so it is gone.
 
> I think I have to implement some kind of reconnect mechanism, signal the condition variable and then not only see if the string is on the map, but also whether or not we are connected. I'm not sure.
 
> What tools do I have in my tool box for this scenario?
 
The condition variable is the least of your problem, when you want to
cancel it you just set a cancel flag and notify the condition variable.
When the waiting thread returns from the wait on a condition, it must
study the state (of the data protected by the associated mutex) anyway
because spurious wake-ups are possible. So studying the cancel flag is
just another check for its state like any other.
 
The hard part is to get the cancel action triggered when the network
goes down, anything related to the network/distributed computations is
very hard to get working correctly in all situations. But I believe this
is something what should be taken care of by your "asynchronous
networked library".
scott@slp53.sl.home (Scott Lurndal): Mar 23 04:47PM


>There is a blocking call in existing code that expects a value to be returned for a given string.
 
>There is an asynchronous networked library that can get that value for the given string.
 
>So, I created a condition variable in the former that gets signaled when a map is updated in the latter.
 
Add a "terminate" flag and check it when the condition variable wait
function returns.
 
#define ACCESS_ONCE(x) (*(volatile typeof(x) *)&(x))
 
void
CLASSNAME::thread_run_method(void)
{
ignore_signals();
g_lock.lock();
while (!ACCESS_ONCE(g_terminate)) {
g_fifoevent.wait(&g_lock);
if (ACCESS_ONCE(g_terminate)) break;
 
c_dlist_iterator di(&g_upstream_queue);
while (di.next()) {
s_wqe *wqep = (s_wqe *)di.curr();
 
process_message(wqep->f_core, wqep->f_message);
wqep->remove();
delete wqep;
}
}
g_lock.unlock();
}
 
 
(g_fifoevent is an instance of c_condition, an abstraction of the pthread_cond_*
functionality, g_lock is an instance of c_lock, an abstraction of pthread_mutex_*).
"Chris M. Thomasson" <invalid@invalid.invalid>: Mar 23 02:13PM -0700

On 3/23/2017 8:50 AM, Christopher Pisz wrote:
 
> Problem is if I get disconnected while waiting, I don't want the calling thread to wait forever and the request for the data over the network has already fired so it is gone.
 
> I think I have to implement some kind of reconnect mechanism, signal the condition variable and then not only see if the string is on the map, but also whether or not we are connected. I'm not sure.
 
> What tools do I have in my tool box for this scenario?
 
Add on, or tweak something to the existing shared conditional state,
that includes the ability to cancel according to your needs. Keep in
mind that the mutex-condvar relationship is atomic wrt waiting. You can
set an aspect of your shared state to "cancel mode", and signal
something. Or heck, broadcast (notify_all) that state mutation to an
entire thread pool.
 
Include reaction code in the worker threads that knows what to do after
a cancel state is noticed, fin?
 
;^)
Christopher Pisz <christopherpisz@gmail.com>: Mar 23 12:08PM -0700

The following comparison fails for an error whom outputs "asio.misc" for errorCode.category().name() and "end of file" for errorCode.message()
 
If it claims to be in category asio.misc, then why does the if condition of (errorCode.category() == boost::asio::error::misc_category ) evaluate to false?
 
Googling says that a boost::system::error_code can have the same value in more than one category, so I assume that in order to get the proper message and meaning we must compare boost::system::error_category as well as boost::system::error_code::value.
 
How do we properly compare the category if this fails to work?
 
Code in question:
//--------------------------------------------------------------------------------------------------
std::string ClientSocketASIO::ErrorCodeToString(const boost::system::error_code & errorCode)
{
std::ostringstream debugMsg;
debugMsg << " Error Category: " << errorCode.category().name() << ". "
<< " Error Message: " << errorCode.message() << ". ";
 
if( errorCode.category() == boost::asio::error::misc_category )
{
switch (errorCode.value())
{
case boost::asio::error::eof:
debugMsg << ". Server has disconnected.";
break;
case boost::asio::error::connection_refused:
debugMsg << ". Connection Refused";
break;
default:
debugMsg << ". Unknown Error.";
break;
}
}
else
{
debugMsg << ". Unknown Error category.";
}
 
return debugMsg.str();
}
woodbrian77@gmail.com: Mar 23 10:14AM -0700

On Wednesday, March 22, 2017 at 11:27:14 PM UTC-5, Alf P. Steinbach wrote:
> > inherited this way or that and I look at my code and ask myself "Um,
> > will any of this stuff I just did perform well in practice or even
> > idiomatic or 'correct' in any way at all?
 
Welcome to the jungle. Welcome to the desert jungle.
And then pray for rain. Cause if it doesn't rain, your
work will go down the drain.
 
 
> boilerplate code, not to mention the casts, repeated all over the place!
> I'd better make my own C extension to deal with all of that, grumble...,
> let's call it, say, "C with classes", yes... to work!
 
I think I've taken a similar approach.
 
 
 
Brian
Ebenezer Enterprises - In G-d we trust.
http://webEbenezer.net
bitrex <bitrex@de.lete.earthlink.net>: Mar 23 01:38PM -0400

On 03/23/2017 05:36 AM, Bo Persson wrote:
 
> https://en.wikiquote.org/wiki/Donald_Knuth#Quotes_about_Donald_Knuth
 
> Bo Persson
 
Got it. I've been using Code::Blocks on Linux, the current version comes
with Valgrind already plugged-in, are there any recommended profiling
tools for that setup?
Cholo Lennon <chololennon@hotmail.com>: Mar 23 12:52PM -0300

On 23/03/2017 10:44, Rick C. Hodgin wrote:
> You cannot know if the code was generated as custom assembly, or by
> compiler output. There are hints and signs, but it's very difficult
> to know in well-optimized code.
 
IDA is able to do that with very good precision (excellent precision
with 'standard' binaries). For unusual cases, it can be tuned it up in
order to help the disassembling process.
 
 
--
Cholo Lennon
Bs.As.
ARG
"Rick C. Hodgin" <rick.c.hodgin@gmail.com>: Mar 23 09:05AM -0700

On Thursday, March 23, 2017 at 11:28:41 AM UTC-4, Bonita Montero wrote:
> on how to analyze the DLL-exports by the help of the lord. ^^
 
> --
> http://facebook.com/bonita.montero/
 
I like you, Bonita. :-)
 
In a way, that's exactly what did happen isn't it? Look at your hand,
for example. In order to do that one act, there are literally like 10
billion things which the Lord had to lay down to make it happen. If
even one of those things weren't there as they are, it would not happen.
Everything we possess comes from Him and His Creation, all the way down
to the operation of atoms and their even smaller components. We owe
the entirety of everything we are and can ever be to Him ... and that's
not just our guidance here in this life, the opportunities we've had,
and so forth ... it's everything even to the point of our existence,
and our place in His Kingdom (either in Heaven, or ... elsewhere).
 
Thank you,
Rick C. Hodgin
"Rick C. Hodgin" <rick.c.hodgin@gmail.com>: Mar 23 09:06AM -0700

On Thursday, March 23, 2017 at 11:52:48 AM UTC-4, Cholo Lennon wrote:
> > binary in a standard form that can be queried upon demand, sent through
> > standard parsing algorithms, which can yield information about what the
> > code contains.
 
It's possible to do it. It's possible to do it reliably in many cases.
It's just not a given that it will always work because you are deriving
things which require assumptions. In most cases they'll be fine, but
not in all.
 
Thank you,
Rick C. Hodgin
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: