Wednesday, August 20, 2008

MBS Basics

MBS Basics.

Wednesday, August 6, 2008

Redirect Standard Out, The old (C) style

We have a third party library that outputs some debug/trace information when executes, this is of course not very nice when you have a command line application that calls the library.

The solution we used is to have a wrapper around the library, which redirects stdout before the call and restores it after.

An initial attempt to do this with Windows APIs (GetStdHandle/SetStdHandle) was unsuccessful probably because C runtime keeps its own handles. So, we had to go down and dirty to the low level C APIs (and this works fine):

    //keep a handle and close stdout
    int handle = _dup(1);

    // call the lib function here

    //restore stdout, close the copy
    _dup2(handle, 1);

Saturday, August 2, 2008

C++ Development with Eclipse

Eclipse has been the only Java IDE I can comfortably use. And while I'm writing C++ code on Windows, Visual Studio is naturally my first choice. But what should I do if I need to develop Linux C++ code (okay, I know vim and xemaces are out there...)?

Luckily, there is Eclipse CDT (C/C++ Development Tools). It seems basically build (with make) and code completion works nice and neatly. What I'd like to test next is to see whether the relatively "tricky" things, such as code completion with templates and smart pointers, might work with this...