297 karma · joined September 8, 2009
I once spent days trying to figure out why a 10 hour timer on a battery charger chip was going off hours too early, leading to the device draining its battery instead of charging it. Turned out the manufacturing partner had substituted another part, functionally equivalent except for the one feature we were relying on...
I can't remember what it was that made me actually look at the chip to check the part number.
So maybe shift 1880 back to 1840.
[0] https://en.wikipedia.org/wiki/Franklin%27s_lost_expedition
[1] https://en.wikipedia.org/wiki/British_Arctic_Expedition
EDIT: formatting
int some_function(...);
int some_other_function(...)
{
int r = -1;
/* imagine a bunch of other locals defined here */
r = some_function(...);
if (-1 == r)
{
return -1;
}
...
}
Now imagine someone changes the return type of some_function(): char *some_function(...);
int some_other_function(...)
{
int r = -1;
/* imagine a bunch of other locals defined here */
char *s;
s = some_function(...);
if (-1 == r)
{
return -1;
}
...
}
Oops! Every other reference to r has been removed except the declaration and the test. Now some_other_function() will always take the early exit, and because r is initialized in its definition the compiler does not complain. (In real life, hilarity ensued.) If it was 'int r;' with no initializer this would have been caught by the compiler.Modern gcc is great at finding uninitialized and unused variables. -Wall -Wextra -Werror FTW.
EDIT: referred to some_function() where it should have been some_other_function().
The point could have been worded better I think.
Very frustrating when it crashes just as you've got the target into the state where you think your bug will trigger. And then GDB repeats the performance reliably for you... On those days you end up resorting to a lot of creative thinking.
I haven't tried it on Windows.
The download instructions say it depends on libffi, libgmp and zlib, which I didn't realise, plus some other tools (gcc, etc.) which I assume are for building packages that wrap C libraries.
http://docs.haskellstack.org/en/stable/install_and_upgrade/#...
When I searched for 'haskell' I got this:
'undefined method `each' for nil:NilClass'
Plus a big stack trace.:-)
Your mileage varies, obviously.
To some extent it's a matter of nomenclature, but one can draw a distinction in C between arrays of arrays and 2D arrays. It does matter. The following is an array of arrays of ints (a "ragged array" as tedunangst mentioned), if I malloc an array of pointers to ints and then add a loop that mallocs an array of ints for each a[i]:
int **a;
a = malloc(N * sizeof(a[0]));
int i;
for(i = 0; i < N; i++)
{
a[i] = malloc(M * sizeof(a[i][0]));
}
Then a[i][j] picks out a single int from the array of arrays. The layout in memory is then like this: +--+--+--+- -+--+
a: | | | | ... | | (array of pointers to arrays of ints)
+--+--+--+- -+--+
| |
| |
| +--+--+--+- -+--+
a[0]: |->| 1| 2| 3| ... | | (array of ints)
+--+--+--+- -+--+
|
| +--+--+--+- -+--+
a[1]: |->|41|42|43| ... | | (array of ints)
+--+--+--+- -+--+
.
.
.
Note that you cannot rely on these arrays to have any relationship with each other in respect to their positions in memory. That's entirely up to malloc(3).However, the following is a 2D array of ints:
int a[3][4];
The same syntax as before can be used to pick out one of the ints in the 2D array: a[i][j]. But this time the C standard gives us that this object is laid out in memory in row-major order. So if you initialize it like this: int a[3][4] = { {1, 2, 3, 4}, { 5, 6, 7, 8 }, { 9, 10, 11, 12 } };
then its memory layout looks like this: +--+--+--+--+--+--+--+--+--+--+--+--+
a: | 1| 2| 3| 4| 5| 6| 7| 8| 9|10|11|12|
+--+--+--+--+--+--+--+--+--+--+--+--+
^ ^ ^ ^ ^ ^
|__a[0]__| |__a[1]__| |__a[2]__|
This means you can index it manually like this: int x = *((int*)a + i * M + j);
where M is the length of each row, in this case M==4. You can't do that with the ragged array-of-arrays.Exercise: try taking sizeof(a) in both cases, as suggested in the grandparent.
Exercise: 3D arrays?
"It's a tablet Christmas there's no doubt about that," said Ben Mcintosh, general manager of technology and entertainment at Harvey Norman. "There is no doubt in my mind that we will sell out of just about every tablet we have in stock by the end of the month."
I'd better go out and get mine before they run out!
Not having a configuration system is a big drawback, enough to make me consider using autoconf in conjunction with Shake. Also you have to know Haskell, which will turn a lot of people away.
I suspect watches may diminish but will always be around because they signal status in a way that hats don't.