On 29/04/2016 8:59 PM, Bernd Oppolzer wrote:
Thank you.
Some of the versions of GCC that I use also checks the arguments of
printf etc.
using the first parameter string constant, if available. When moving
programs
from OS/2 to Linux, I discovered some hidden errors this way.
IIRC clang has something similar where you can lint when compiling.
Very, very nice. But it's not portable.
WRT iostreams I recently worked on some code where converting STCK units
to text strings was very expensive using standard methods because a
conversion to floating point was required. I wrote a custom formatter
which resulted in a x10 performance increase by using builtins. I didn't
need to drop down to assembler to do so.
stck>>=12;// convert to microseconds
chardecwork[16];// decimal output work area
__cvdg( stck, decwork);
charMASK[]=
"\x40\x20\x20\x20\x20\x20\x20\x20\x21\x20\x4B\x20\x20\x20\x20\x20\x20";
chartime[sizeofMASK-1];
memcpy( time, MASK, sizeoftime);
__ed( (unsignedchar*)time,
(unsignedchar*)decwork+8,
sizeoftime-1);
I think it's a good idea to have different compilers at hand; if you
have a critical
piece of software, use all of them. Same goes for operating systems;
my C programs
should run the same way on Windows, Linux, OS/2 and z/OS ... sometimes
some
errors show up only on one of the platforms ...
Kind regards
Bernd
Am 29.04.2016 um 14:49 schrieb David Crayford:
That's an excellent answer Bernd! One of the reasons why I prefer C++
over C is that iostreams are not only typesafe but they handle
variable length parameter lists by simple function calls. The
downside is that the extra function call overhead is more expensive
so it's a trade-off. It's also significantly more verbose than a
simple printf() but there are decent alternatives
http://www.boost.org/doc/libs/1_60_0/libs/format/doc/format.html.
Just for fun http://www.horstmann.com/.
----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN
----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN