long long on Windows/Dev-C++/MinGW

22nd of April, 2008

[sarcasm on]
(because Moldova is probably the last country where programming competitions are still held on Windows)
[sarcasm off]

The long long data type has been introduced in C as part of the C99 standard. On 32-bit machines it is a 64-bit signed integer data type. The printf/scanf formatting string for this type is %lld.

Using Dev-C++ and the MinGW port of the GNU C Compiler on Windows, one would expect programs to run the same way they do with GCC on Linux. But no! Apparently MinGW calls the Windows libraries, so every time you call printf or scanf you’ll end up using Microsoft’s version of the functions!

And of course Microsoft cares about backwards compatibility, so when C99 was published they didn’t switch to the standard, keeping their non-standard %I64d formatting string instead!

[subsides into an angry stream of unintelligible muttering]


How Linux Handles Summer Time

3rd of April, 2008

Daylight Saving Time is a controversial policy, but if you live in a region where it’s used, there’s not much you can do about it.

Linux adjusts the clock automatically, using zoneinfo. You can find out when these changes happened / are scheduled to happen using the zdump tool:

zdump -v Europe/Chisinau

The argument should be a path relative to /usr/share/zoneinfo/. A quick hint that you got it wrong is if you only get four entries (for the limits of time ;) ), 1901 and 2038 here, for instance.

P.S. If you have other operating systems on your machine, you should only allow one of them to change the time, otherwise you’ll get your clock shifted by more than one hour.


Python Trick: Subtracting Dates

3rd of April, 2008

I’m not the Python genius I want to be, so here’s this, for future reference:

How to subtract one date from another, and get the result in days:


from datetime import date
(date(2008, 3, 31) - date(2005, 2, 1)).days

A simple application:


party = date(2008, 6, 1)
(party -  date.today()).days

Konvert2Ogg 0.2 is here

21st of March, 2008

Finally,

after a complete redesign,

and a complete code rewrite,

released under a full moon,

feature-complete and usable,

[drum roll],

[fireworks],

Konvert2Ogg 0.2 is here.

(updated) Home page
SourceForge.net project page
KDE-Apps.org page

I am especially thrilled about what I’ve learned while developing this project:

  • How to implement a factory in C++, so that when I want to add a new class, I don’t need to add references to it all over the place.
  • As a bonus, make that factory a singleton ;)
  • Lots of things about Qt, KDE, and even svn, XHTML and CSS, that I could only learn hands-on. (too many to list)
  • I even fixed some bugs / made some improvements to kdelibs while working on K2O!
  • Probably a bunch of other stuff I am forgetting right now.

Although the program now works and does what I want, this is no way the end of the journey. There are many more cool things in the can :D


People born today age four times slower.

29th of February, 2008

In other completely random news:

  • School’s out for a week!
  • Konvert2Ogg, the KDE project I’m working on, has a new mission statement and code and GUI design. I am especially satisfied with the way the singleton / object factory (as taught by Alexandrescu) has turned out. With the factory and the base classes in place, adding support for Oggenc took only a few minutes.
    k2o-for-blog.png
    Wait for version 0.2 sometime in the next few weeks.