Binary Files And VCS

I've already written about why you should not add binary files to your code repository but, there are some cases where it seems you cannot do otherwise. Deliverables The main exception to the general rule is for images and other files that are part o… (read more)

The Size Of Strings

It's quite common to find pieces of C code like the following: void do_something() { const char foo[] = "This is foo"; ... func(foo, sizeof(foo)); ... } This is perfectly legal in C and, as you can try by yourself, s… (read more)

Never Ever Add Binary Files To Your VCS

OK, sometimes you are allowed to keep track of blobs but only if you have no alternatives. There are very few situations where you cannot do otherwise: for example when you need to track Linux symbolic links in a version control system thought for Wi… (read more)

GCC Is Your Friend

A couple of years ago, I wanted to put some functions to write logs into a C library (shared object). My idea was to have something that was easy to use in every situation. Since, most of the times, variables must be printed, I decided to create a fu… (read more)

4 Easy Tips To Work Better With Git

Maybe they are quite trivial and only come from common sense, but sometimes it's useful to repeat. By the way, these are general purpose suggestions that can be used also with other versioning systems. 1. Use Tags To Label Versions Every single relea… (read more)

How To Recover Deleted Git Commits

In many Git tutorials it's written: "never use git reset --hard". And there is a good reason: this command deletes commits, and, if you don't have pushed them to a remote repository, your changes are lost (at least, if you don't know where to find th… (read more)

Bitwise Right Shift With Signed Int

It's never too late to learn something new. And sometimes the compiler is smarter than what you think. In this case, I've discovered this behavior a couple of weeks ago while I was working on a C function that manipulates the bits of an unsigned inte… (read more)