Random ramblings, mostly technical

Wiktor writes about stuff.

C programming with Windows


It’s been almost a year since I switched jobs. In the previous one we had Linux-based development environment for not-so-embedded devices, where I could use C, C++, Python and Bash (with little of node.js on top) in a single project. After I transferred, I had to dive into actually embedded, C-only project with MS Windows used as main OS on every machine.

After the initial shock (“Why can’t these windows manage themselves?!”) I started slowly setting up my configuration, trying to recreate well-working setup I had before. Some things worked, some did not. I discovered few useful tools and wasted some time chasing the unobtainable ones. Below you can find a short list of programs I use in my coding setup.


The Editor. I started tinkering with it under Linux mid-2013. Coming from vim (which still remains irreplaceable when connecting remotely!), I went with Evil from the start, which helped immensely with the transition. Muscle memory for vi shorcuts serves me very well. I use Emacs mainly for coding, maintaining documentation and notes (org-mode!) and for pretty much anything that comes to mind (like displaying notifications, connecting to remote servers, etc). It’s crazy extensible and has very active community. To be fair, it also has its drawbacks, like handling the large files (doable, not the smoothest) and very long lines (there are many solutions online, but no perfect one). Emacs is extremely customizable and has vast number of plugins - my current instalation has almost fifty of them. From code snippets engine, through git, spellchecking, syntax checking, external apps integration to various color schemes - if you need something, there probably is a mode (plugin) for it.


Cscope is a tool, which allows the programmer to dig around in the project’s source code. I use it solely for C, and it is perfect for quick jumping to definitions and tracking down execution chains. In terms of speed it beats the good old grep and even ag (which I highly recommend). The main disadvantage of cscope is the necessity to rebuild its database every time the codebase changes, which could become tedious in large projects. It also requires a workaround under Windows, which I plan to describe shortly. It is possible to run it from commandline, but for convenience I use helm-cscope, which provides nice, unified interface inside Emacs.

/img/02-helmcscope.png Figure 1: Searching for symbol in Emacs with helm-cscope.


I feel guilty not starting with this one. Cygwin offers you the familiar tools you had to ditch moving to Windows. From sed, grep, and find to sshd and gcc - everything works, with very little trouble on the way. There are some unavoidable quirks, but overall I cannot imagine being productive on Windows without Cygwin.


There are more applications I use every day, but I’m planning a separate post for all Windows programs that I run frequently. When it comes down to user’s satisfaction, I still feel like I’m struggling with the environment and I would be more productive running Linux. I make small improvements every day, but there are some things that just cannot be fixed (I am looking at you, window management!). Hopefully, one day I would be able to return to the environment, which will be driven only by my choice.