Tuesday, October 14, 2014

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

comp.lang.c++@googlegroups.com Google Groups
Unsure why you received this message? You previously subscribed to digests from this group, but we haven't been sending them for a while. We fixed that, but if you don't want to get these messages, send an email to comp.lang.c+++unsubscribe@googlegroups.com.
"Rick C. Hodgin" <rick.c.hodgin@gmail.com>: Oct 14 09:04AM -0700

On Tuesday, October 14, 2014 11:16:32 AM UTC-4, Luca Risolia wrote:
> > GCC does also give
> > several false positives, however.
 
> hm..false positives? for example?
 
Line 322:
https://github.com/RickCHodgin/libsf/blob/master/source/vjr/sound/sound.cpp
 
Line 50:
https://github.com/RickCHodgin/libsf/blob/master/source/vjr/engine.cpp
 
You can use CodeLite and MinGW 4.8.1. Download CodeLite with MinGW
4.8.1 bundled:
http://www.libsf.org/software/
 
If you load vjr.workspace from here:
https://github.com/RickCHodgin/libsf/tree/master/source/vjr/vjr_mingw_gcc_codelite
 
And have cloned the project into c:\libsf\ ... then you'll see the
warnings GCC gives. In tracing through the code, I don't see why
they're being given (specifically the warning on lfHertz4, as it
does not give one on lfHertz1..3).
 
Best regards,
Rick C. Hodgin
Christopher Pisz <nospam@notanaddress.com>: Oct 14 11:07AM -0500

On 10/14/2014 9:30 AM, Robert Hutchings wrote:
> Do you use an IDE like Code::Blocks or Eclipse? Or just Emacs or
> vi/gcc/g++ on Linux/UNIX?
 
> What about testing and debugging? Favorite tools?
 
Seeing how all my jobs have been targeting Windows platforms, except for
one, since graduation, my tools are "an MSDN subscription"
 
I liked Intel's Parallel studio for memory leak and deadlock detection,
but like all memory leak tools it goes bananas when going over a COM
boundry. COM needs to die and the world would be a better place without it.
Jorgen Grahn <grahn+nntp@snipabacken.se>: Oct 14 08:59PM

On Tue, 2014-10-14, Robert Hutchings wrote:
> Do you use an IDE like Code::Blocks or Eclipse? Or just Emacs or
> vi/gcc/g++ on Linux/UNIX?
 
g++, Make, Emacs, Git, zsh and the infinite Unix toolbox.
 
> What about testing and debugging? Favorite tools?
 
Valgrind, tcpdmp, strace and ltrace. And the rest of Unix.
 
/Jorgen
 
--
// Jorgen Grahn <grahn@ Oo o. . .
\X/ snipabacken.se> O o .
Marcel Mueller <news.5.maazl@spamgourmet.org>: Oct 14 11:37PM +0200

On 14.10.14 17.00, Rick C. Hodgin wrote:
 
>> What about testing and debugging? Favorite tools?
 
> Windows: Visual Studio 2003, Visual Studio 2008. You cannot beat
> edit-and-continue.
 
I had not even one existing real life project where it ever worked
(VS2003, 2008, 2012). For me it only works for power point slides or
simple examples.
The only effect when I turn it on is that the code can no longer be
modified while debugging, which is even worse than without the feature.
I should note, that I usually work with web applications.
 
> There is no other ability to write code which is
> better suited to debugging.
 
In theory, yes.
 
> I also use the Visual Assist X plugin
> for Visual Studio, which adds a lot of refactoring abilities which
> make development so much nicer.
 
Well, refactoring is no powerful side of VS (without external tools).
Eclipse had always been far ahead of it.
 
> Linux: CodeLite IDE with GCC and GDB, though I find GDB to be hideous
> and awful compared to Visual Studio's debugger.
 
Well, and gdb is almost unusable without additional tools. The user
interface is horrible. It's strength is remoting over platform
boundaries, e.g. debugging ARM from x64.
When remote debugging with VS the speed decreases by some orders of
magnitude, almost unusable. Unfortunately x64 seem to trigger remote
debugging also even if you operate locally because VS is restricted to
32 bit. So we build all our .NET applications for any CPU and run it as
x86 even on x64 platforms, although this causes some performance
penalty, e.g. because atomic operations (Interlocked.*) with 64 bit
operands like long or DateTime create runtime overhead.
 
> The IDE is close
> enough, and GCC has vastly superior warnings and error catching.
 
First of all gcc can usually compile C++ code without major errors. With
VS I had problems to compile standard conform C++ code several times.
OK, I did not use much C++ with VS in the last years. In fact I talk
about VS <= 2008.
 
> GCC does also give several false positives, however.
 
Ack, sometimes.
 
 
Marcel
Ian Collins <ian-news@hotmail.com>: Oct 15 10:45AM +1300

Robert Hutchings wrote:
> Do you use an IDE like Code::Blocks or Eclipse? Or just Emacs or
> vi/gcc/g++ on Linux/UNIX?
 
Solaris Studio, g++, NetBeans (on Linux/Mac)
 
> What about testing and debugging? Favorite tools?
 
CppUnit, dtrace, dbx, gdb (on Linux/Mac/Arm).
 
--
Ian Collins
David Brown <david.brown@hesbynett.no>: Oct 14 11:47PM +0200

On 14/10/14 18:04, Rick C. Hodgin wrote:
> warnings GCC gives. In tracing through the code, I don't see why
> they're being given (specifically the warning on lfHertz4, as it
> does not give one on lfHertz1..3).
 
Without giving any information about the warning, the compiler flags
used, or giving code that can be compiled and tested (and I don't mean
by cloning your whole project), that's about as useful as telling your
car workshop that your car has a problem and you hope they can fix it.
 
Write a minimal, stand-alone, compilable code snippet, and people can
test it perhaps help you out.
 
Oh, and declaring all your local variables at the start of a function
went out of fashion in C at the end of last century, and has never been
in fashion in C++. There are good reasons for minimising the scope of
your locals.
 
It is certainly possible for gcc (or any static error checking system)
to produce false positives - some types of test are particularly prone
to it since the compiler doesn't know /everything/ about the program or
the data passing through functions. But sometimes what appears to be
false positives are not false at all, so it is worth checking out.
Marcel Mueller <news.5.maazl@spamgourmet.org>: Oct 14 11:48PM +0200

On 14.10.14 17.16, Luca Risolia wrote:
>> GCC does also give
>> several false positives, however.
 
> hm..false positives? for example?
 
E.g. if you have an abstract base with a non virtual but protected
destructor it warns about the non virtual destructor although objects of
this type normally cannot be destroyed by a pointer to the abstract base.
 
 
Marcel
"Rick C. Hodgin" <rick.c.hodgin@gmail.com>: Oct 14 03:05PM -0700

On Tuesday, October 14, 2014 5:47:49 PM UTC-4, David Brown wrote:
> Write a minimal, stand-alone, compilable code snippet, and people can
> test it perhaps help you out.
 
I've lived with the GCC warnings since whenever it was I added GCC
support. I'm content with the false positives. I haven't disabled
the warnings they give because I don't want to miss other warnings
on other source lines that are legitimate.
 
The .mak files is in the vjr_mingw_gcc_codelite directory.
 
> went out of fashion in C at the end of last century, and has never been
> in fashion in C++. There are good reasons for minimising the scope of
> your locals.
 
I prefer to have my code documented so that a person entering one of my
functions can, at a glance, generally know a lot about the function
before they even get started.
 
I use naming conventions. Names that do not have a leading "i" are
outward facing, such as "compute_data" and "parse_file". If they
have a leading i, they are internal functions, such as "iComputeData"
and "iParseFile" which means a few assumptions can be made about them
because the i-functions won't be called unless they've already passed
some degree of scrutiny through the outward-facing functions. I also
have "ii" functions, which are called from there, which are called
without any parameter checking, because it is known by the caller that
everything will be in proper order.
 
At the top are all of the local variables. My Visual Studio IDE has
a feature called "CodeView" which, when I highlight a variable, it
shows me where it's defined. By putting all variables at the same
location, when I position the flashing caret onto any of them, they
are all shown in that window, along with their types.
 
I categorically disagree with minimizing the scope of variables. I
think it's a bad idea and I do not write code that way. If I need
multiple variables, then I give them each unique names, and in that
way there is no ambiguity if the variable "i" here is the one in this
scope, or that scope, or the one declared over there, or the one
passed in as a parameter. Everything has its place. It also aids in
debugging because you simply have to type the name, and not try to
find the instance or reference of the name as the 3rd version of i
that's in use.
 
> to it since the compiler doesn't know /everything/ about the program or
> the data passing through functions. But sometimes what appears to be
> false positives are not false at all, so it is worth checking out.
 
They don't bother me. I couldn't figure out at first why I was getting
them and assumed there was something wrong in my code ... but as it is
everything works, and I don't believe there are flaws in my logic. The
error with regards to "var" is a particularly confusing one though. I
use the "var" variable in assignment as I do so I can examine it in the
debugger, but I don't use it other places. GCC doesn't like that.
 
Best regards,
Rick C. Hodgin
Marcel Mueller <news.5.maazl@spamgourmet.org>: Oct 15 12:07AM +0200

On 14.10.14 16.30, Robert Hutchings wrote:
> Do you use an IDE like Code::Blocks or Eclipse?
 
My personal favorite is CDT. It is free and quite good with respect to
code completion and refactoring. OK, working with the Linux kernel
source tree is a bit slow.
 
> Or just Emacs or
> vi/gcc/g++ on Linux/UNIX?
 
vi - urgh, only in the thread of force. It might be powerful from the
functional point of view but the user interface is from the seventies.
 
> What about testing and debugging? Favorite tools?
 
Well, debugging depends on the target platform. The best debugger is the
one available on your platform.
And testing is for milksops. :-) Kidding aside, it really depends on the
kind of tests. Can your code operate isolated? Do you need a well
defined DB setup? Do you intend to test the UI? And so on. But most
companies do not want to spent the additional money/effort for automated
testing the first time. They rather spend the money every time for non
automated tests. ;-)
 
 
Marcel
Luca Risolia <luca.risolia@linux-projects.org>: Oct 15 12:40AM +0200

Il 14/10/2014 23:48, Marcel Mueller ha scritto:
 
>> hm..false positives? for example?
 
> E.g. if you have an abstract base with a non virtual but protected
> destructor it warns about the non virtual destructor
 
I personally don't get any warnings with -Wall and -pedantic turned
on...This is GCC 4.9.0
Luca Risolia <luca.risolia@linux-projects.org>: Oct 15 12:50AM +0200

Il 14/10/2014 18:04, Rick C. Hodgin ha scritto:
> https://github.com/RickCHodgin/libsf/blob/master/source/vjr/sound/sound.cpp
 
> Line 50:
> https://github.com/RickCHodgin/libsf/blob/master/source/vjr/engine.cpp
 
Can you isolate the code producing those false positives in a minimal,
compilable example that I can test on my Linux machine?
Nikki Locke <nikki@trumphurst.com>: Oct 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 cpplibs@trumphurst.com
Marcel Mueller <news.5.maazl@spamgourmet.org>: Oct 15 12:17AM +0200

On 13.10.14 23.56, Mr Flibble wrote:
> Herb Sutter's new "Unified Call Syntax"
> (https://isocpp.org/files/papers/N4165.pdf) looks convincing (the
> initial idea gave me a mental rash though).
 
Hmm, it looks like a reinvention of .NET extension methods.
 
What I dislike is the arbitrary preference of one parameter. On the
other hand it is a neat way to provide derived interface methods without
blowing up the interface.
 
 
Marcel
Christopher Pisz <nospam@notanaddress.com>: Oct 14 02:33PM -0500

How would you go about converting a structure that is 96 bits plus a the
sign and an int for the scale into a string?
 
Its a fabulous Windows type and I can't seem to find anything on it.
http://msdn.microsoft.com/en-us/library/windows/desktop/ms221061(v=vs.85).aspx
 
I could fairly easily do 32 bits or even 64, but I am not sure how to go
about 96 because anything I stuff it into previous to putting it in a
stringstream wouldn't be large enough and I'd think I would have to put
it into something before flipping the sign and putting in a decimal place.
 
I might see if I can just insert all the numbers into a stringstream and
then insert a sign into the front and a decimal into its place using
string random access and insert operators in the meanwhile. I wonder if
anyone has suggestions on this in the meanwhile.
"Rick C. Hodgin" <rick.c.hodgin@gmail.com>: Oct 14 12:46PM -0700

On Tuesday, October 14, 2014 3:33:20 PM UTC-4, Christopher Pisz wrote:
> then insert a sign into the front and a decimal into its place using
> string random access and insert operators in the meanwhile. I wonder if
> anyone has suggestions on this in the meanwhile.
 
If you can't find support anywhere else...
 
There's a well-proven library called MPFR. You could create an arbitrary
length integer, set it to 0, save it to memory, and then populate over
those 96 bits, and load it back in that way, and then use their MPFR
equivalent printf() functions.
 
There are various C++ wrapper classes for it. Google "MPFR C++ wrapper"
and you'll find some.
 
Best regards,
Rick C. Hodgin
Christopher Pisz <nospam@notanaddress.com>: Oct 14 02:47PM -0500

On 10/14/2014 2:33 PM, Christopher Pisz wrote:
> then insert a sign into the front and a decimal into its place using
> string random access and insert operators in the meanwhile. I wonder if
> anyone has suggestions on this in the meanwhile.
 
Here is my first attempt. unfortunately, I don't even know how to
initialize this monstrosity. I am going to try and get some test data to
compare against and verify.
 
I realize this is a Windows type and I should (and am) asking on the
Windows forums, but just looking for the native C++ tips here, since
there might be a better solution than using stringstreams and string
operators.
 
 
//------------------------------------------------------------------------------
std::string DecimalToString(const DECIMAL & decimal)
{
std::ostringstream converter;
 
converter << decimal.Hi32;
converter << decimal.Lo64;
 
if( !decimal.sign )
{
converter.str().insert(converter.str().begin(), '+');
}
else
{
converter.str().insert(converter.str().begin(), '-');
}
 
converter.str().insert(converter.str().back() - (decimal.scale +
1), '.');
 
return converter.str();
}
Victor Bazarov <v.bazarov@comcast.invalid>: Oct 14 04:13PM -0400

On 10/14/2014 3:47 PM, Christopher Pisz wrote:
> 1), '.');
 
> return converter.str();
> }
 
From what I know about 'ostringstream', its 'str' member function
returns a temporary. So, even if you call 'insert' on that temporary in
the right place, it's not going to change the 'converter's own internal
string. I recommend you to manipulate a string, not the stream, in your
'DecimalToString' function. Something like
 
converter << ...
converter << ...
 
std::string output(converter.str());
if (...
output.insert(...
else
...
 
return output;
}
 
V
--
I do not respond to top-posted replies, please don't ask
Robert Wessel <robertwessel2@yahoo.com>: Oct 14 04:42PM -0500

On Tue, 14 Oct 2014 14:33:06 -0500, Christopher Pisz
>then insert a sign into the front and a decimal into its place using
>string random access and insert operators in the meanwhile. I wonder if
>anyone has suggestions on this in the meanwhile.
 
 
Assuming performance is not too critical, something like:
 
void cvtDECIMAL(DECIMAL &dec)
{
ULONG hi, mid, low, c;
ULONGLONG t;
int i;
 
hi = dec.Hi32;
mid = dec.Mid32;
low = dec.Lo32;
 
for (i=0; i<29; i++)
{
c = hi % 10;
hi /= 10;
 
t = c * ULONG_MAX; // I don't remember the exact macro name
t += mid;
c = t % 10;
mid = t / 10;
 
t = c * ULONG_MAX; // I don't remember the exact macro name
t += low;
c = t % 10;
low = t / 10;
 
output("0"+c);
}
}
 
gets you most of the way there, using basic long division. It happens
to output the digits in reverse, does not apply the scale factor, does
not suppress leading zeros, and doesn't output the sign, but those
should be easy to deal with.
Paul N <gw7rib@aol.com>: Oct 14 02:33PM -0700

On Tuesday, 14 October 2014 09:17:22 UTC+1, Rick C. Hodgin wrote:
 
> a local variable. Or include a pointer and
 
> populate the thing being pointed to so it is
 
> never a question.
 
I've now tried it with a static local variable and this seems to work. So perhaps I'll leave it at that. I'm still baffled as to why the other version did not work, however, plus have a slight nagging feeling that there still might be something wrong, as I don't see how I've "fixed" it.
 
Thanks.
Paul.
Martijn Lievaart <m@rtij.nl.invlalid>: Oct 14 08:44PM +0200

On Sun, 12 Oct 2014 16:47:55 +0200, Emanuel Berg wrote:
 
> Other than that C and C++ are two different languages with different
> syntax, tools, and (as you mention) libraries. Tho the biggest
> difference by far is the C++ focus on OO.
 
And generic programming. So the two biggest differences are by far the
focus on OO and generic programming. And the STL. So the three biggest
differences...
 
Never mind, I'll get my coat.
 
M4
Jorgen Grahn <grahn+nntp@snipabacken.se>: Oct 14 09:16PM

On Sun, 2014-10-12, Emanuel Berg wrote:
>> type system (new/delete, templated casts, bool, enum
>> class, ... ) - constexpr - templates
 
> Again, a lot of those things are to my mind OO.
 
According to most people's definitions, they're not. See e.g.
 
http://en.wikipedia.org/wiki/Object-oriented_programming
 
Not that I understand why polymorphism and inheritance are neccessary
parts of OOP, but Stroustrup seems to include that in his definition
too.
 
/Jorgen
 
--
// Jorgen Grahn <grahn@ Oo o. . .
\X/ snipabacken.se> O o .
"Tobias Müller" <troplin@bluewin.ch>: Oct 14 03:41PM

> "this" and the outer class's parameters are all knowable.
 
> What is the explicit prohibition here, does anyone know?
 
> cts
 
This is not valid C++, not even close. Did you mean something like that:
 
class O
{
O(): i(this) {}
 
class I
{
I(O* o): o_(o) {}
O* o_;
} i;
};
 
This should work as long as you just access the pointer in the constructor
of I. The outer object is not ready for use yet, because its constructor is
not yet finished.
Not sure if its really legal though.
 
Tobi
"Tobias Müller" <troplin@bluewin.ch>: Oct 14 03:43PM

> } i;
> };
 
> This should work as long as you just
 
s/just/don't/
 
Victor Bazarov <v.bazarov@comcast.invalid>: Oct 14 11:58AM -0400

On 10/14/2014 11:41 AM, Tobias Müller wrote:
> of I. The outer object is not ready for use yet, because its constructor is
> not yet finished.
> Not sure if its really legal though.
 
The address of the containing object (the 'o' argument) in the 'I's
c-tor is *perfectly fine*, the memory for it has been allocated; no
other operation is guaranteed to have been done. The 'this' pointer is
explicitly allowed to be passed to other functions (like the 'I's c-tor)
in O's initializer list, with the specific disclaimer that the object is
not yet fully constructed, as you point out. I wasn't able to find a
quote from the Standard in a brief search, and am too lazy to look more
thoroughly.
 
V
--
I do not respond to top-posted replies, please don't ask
Emanuel Berg <embe8573@student.uu.se>: Oct 11 05:18AM +0200


>> I would like to have the program sleep for a fixed
>> amount of milliseconds each time a loop iterates.
 
> Did you try the obvious (for Unix/Linux): usleep()?
 
No. Why, is that better than sleep_for?
 
--
underground experts united
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: