pure
@pure
Best posts made by pure
Latest posts made by pure
-
RE: C code sample for interview
@Steve The Cynic said:
Inconsistent behaviour between platforms is hardly a surprise. Nobody has mentioned the reason, though. The words you are looking for are "undefined behaviour" and as you should all know that means "demons fly out of your nose" or "millions die in a nuclear fireball", although the latter applies only when the code is running on a DeathStation 9000.
Hence why inttypes.h exists. From the (linux) manpage:
APPLICATION USAGE The purpose of <inttypes.h> is to provide a set of integer types whose definitions are consistent across machines and independent of operating systems and other implementation idiosyncrasies. It defines, via typedef, integer types of various sizes. Implementations are free to typedef them as ISO C standard integer types or extensions that they support. Consistent use of this header will greatly increase the portability of applications across platforms.
-
RE: C code sample for interview
I think the world would be a better place if it used PRIx64 from inttypes.h
#include <stdio.h> #include <inttypes.h>
int main (int argc , char ** argv)
{
uint64_t a = 0xC0FFEE;
uint64_t b = 0xBADBEEF;printf("a: %" PRIx64 "\nb: %" PRIx64 "\n", a, b); return 0;
}
Output:
a: c0ffee b: badbeef
or did i miss something?
-
RE: The Redirector
@snoofle said:
If we hadn't run this test, it would've gotten released to production with everything hanging off of a local copy of unreleased software running on a roaming laptop.
really? The production is on the same network as the guy's development laptop?!
Surely not.
-
RE: Subversion comments
@Rick said:
@pure said:
One word - nondeterminism.
At least, I think that is a word.
Anyway, queue someone bringing up Why Threads are a Bad Idea (for most purposes)
That was written in 1996 when using anything but a single processor was unusual. It is 17 years later. Move on.
No doubt. I particularly like the way it refers to anyone who knows a bit of C++ as a "Wizard". And more ludicrously, that people who know C++ somehow greater than people who "only" know C.
It's right about VB programmers, though, right ?!
Seriously, though, in my experience most developers even now don't know how to write reentrant code or avoid deadlocks (or, worse, go so far out of their way to remove deadlocks, that the app spends 90% of its time fiddling with locks or waiting for them). And this certainly doesn't just apply to youngsters.
There's a fairly famous attempt to speed up a part of our application with threads. The release note claimed something ludicrous like 1000x better performance. Lots of work was done over lots of man-months. The result? Stuff like this:
void GotSomeData(const char * someData)
{
if (Logger.IsLoggingLevelEnabled(1))
{
Logger.write("did some stuff with: %s", someData);
}// pass the data on to the "main" thread messageQueueForData.Put(someData);
}
Naturally, this was executed in a whole bunch of threads which sat waiting for "someData" to pass around. Anyway, you've probably guessed that the Logger.IsLoggingLevelEnabled method is syncronised (i.e. implemented as GetLock(); DoStuff();. ReleaseLock(); or whatever), so the performance of the system was: worse
-
RE: Subversion comments
One word - nondeterminism.
At least, I think that is a word.
Anyway, queue someone bringing up Why Threads are a Bad Idea (for most purposes)
-
RE: The tale of min and max.
I should probably say that I wasn't having a go at Microsoft particularly. The decision to do such a thing in any code (particularly header files) is WTF and it would be WTF in any API or set of headers. This thread happened to be talking about a Microsoft package with which I'm not familiar.
-
RE: The tale of min and max.
The options aren't the WTF. The #defines in Microsoft's standard headers are the WTFs.
The C++ FAQ Lite is great fun with regards macros. For example:
@C++ FAQ Lite said:
39.5 What should be done with macros that have multiple lines?
Answer: Choke, gag, cough. Macros are evil in 4 different ways: evil#1, evil#2, evil#3, and evil#4. Kill them all!! (Just kidding.)
.... answer ....
-
RE: Are people REALLY this dumb?
O man. That guy is from like 5 minutes from where I grew up.
Seriously, my address was...