Hi! You are viewing the archive of unrelenting.technology. This website is no longer updated, my current one is val.packett.cool. Check it out instead :)

Tag #c

Sometimes I waste hours of debugging on really really silly things…

Why do I keep thinking that e.g. 0 || 69 (typically written with variables obviously) in C would return 69 rather than 1?! Well it must be because C’s β€œbooleans are just numbers” thing makes me think that the operators would also do… number things. No they don’t! >_<

True story:

A friend is writing some C++ in Visual Studio. There’s a template class with a copy constructor like this one:

    SomeThingClass(const SomeThignClass& other) { …

She asks me about the weird error on this line – something about the β€œreturn type is int by default” behavior from old C not being allowed anymore. What the hell, this is a constructor. We spend, like, ten minutes in a WTF state.

Then we decide to copy the code to my laptop and compile with clang.

 error: no template named 'SomeThignClass'; did you mean 'SomeThingClass'?

Moral of the story: even two people can just not notice a little typo where the oredr of lettres is swapepd. Computers are better at this. UNLESS THE COMPUTER IS RUNNING MSVC