Articles tagged C/C++

  1. Relative RPath Settings with CMake

    The run-time search path (rpath) defines paths to search for dynamic libraries when executing a program. It is a mechanism on Linux parallel to the LD_LIBRARY_PATH environment variable, which is another hint to find dynamic libraries.

    Usually, it is a good idea to make software which you built relocatable. This means that created binaries can be...

    Read more
  2. Using Dependency Tracking in Jenkins with CMake-based C++ Projects

    If you are building multiple related software projects with a continuous integration server one important aspect is to be notified when changes in an upstream job break the build or tests for a downstream job. This involves knowing which exact build numbers of the upstream and the downstream job are involved.

    The Jenkins continuous integration server...

    Read more
  3. Gcov Coverage Reports in Jenkins

    I am currently evaluating the applicability and limitations of the Jenkins continuous integration server for C++ development. Besides several limitations which are mainly caused by the complexity of C++, Jenkins provides a solid basis for continuous integration of C++ projects.

    One thing which I was not happy with so far was the missing integration...

    Read more
  4. Boost bind and smart pointers

    I've seen this several times causing troubles:

    1
    2
    
    boost::shared_ptr<Foo> p(new Foo);
    boost::thread t(boost::bind(&Foo::method, p.get()))
    

    This prevents the livecycle management of shared_ptr or any other smart pointer to be effective in the thread. Hence, p may get destructed even though the thread is still active.

    Boost bind can handle smart...

    Read more
  5. Ignoring Warnings from System Headers

    Compiling C and C++ code with the highest warning levels is a good practice and helps spotting potential errors. For GCC the flags

    1
    
    -Wall -Wextra
    

    will generate a lot of useful warning messages about unused parameters etc.

    Unfortunately, this is not the common practice and often the own compiler settings concerning the warning level results in...

    Read more
  6. Unused Parameters in C++

    Just some quick thought on how to handle compiler warnings about unused parameters in C++ code. While these warnings are helpful most of the time, sometimes you simply have to ignore a parameter that is required by an interface definition. Then you got three solutions to remove the warning:

    1. Change the compiler flags. The worst solution....

    Read more
  7. Using googlemock with the Boost Test Library

    googlemock is a framework that allows generating mock objects for unit tests. I've decided to use this framework as it looks wells designed and maintained. The default is to use googlemock with Google's unit testing framework googletest, but as I was already using the Boost Testing Library, I was searching for a solution to use googlemock in Boost...

    Read more
  8. Doxygen Support in Eclipse CDT

    Since a long time I was wondering why CDT, the C++ support for the Eclipse IDE, doesn't have a decent support for highlighting and creating comments in the Doxygen format. Today, while searching for customizable code templates per project, I found the setting to enable Doxygen support. It is located in the project properties at "C/C++ General". Not...

    Read more
  9. Highlights aus der Boost Graph Library

    Template Programming to the Extreme… Manchmal macht es echt eine Freude den Quellcode der BGL (Boost Graph Library) zu lesen. Hier ein paar Highlights:

    1
    2
    3
    4
    5
    6
    
    typename T::ThereReallyIsNoMemberByThisNameInT vertices(T const&);
    
    // The graph is passed by *const* reference so that graph adaptors
    // (temporaries) can be passed into this function...
    Read more
  10. Out-of-Source Builds mit CMake

    In der Java-Welt gibt es schon lange die sinnvolle Konvention kompilierte class-Dateien in einer anderen Verzeichnisstruktur abzulegen als den Quellcode. So eine eine Konvention hat viele Vorteile:

    • Falls der Quellcode in ein Versionskontrollsystem eingecheckt wird (und das sollte er auf jeden Fall), müssen nicht umständliche Regeln zum Excluden...
    Read more
  11. OpenCV-Tutorial

    Im Rahmen der Veranstaltung "Computer Vision Toolkits - Vom Sensor zu System" in diesem Semester, habe ich ein Tutorial über OpenCV, die "Open Source Computer Vision Library", geschrieben, dass den grundsätzlichen Umgang mit ihr beschreibt. Da das für den ein oder anderen sicher interessant ist, gibt es das Tutorial jetzt auch hier online.

    • Tutorial...
    Read more
  12. Grundregeln des API-Designs

    API-Design ist sicherlich keine einfache Sachen, aber es gibt schon ein paar Grundregeln, an die man sich relativ problemlos halten kann. Ein gute Auflistung dieser Regeln liefert z.B. der Blog Eintrag "API Design Guidelines".

    Einer der wichtigsten Punkte wird im genannten Text unter "Be intuitive" aufgeführt: "Use consistent parameter ordering...

    Read more
  13. Magische Konstanten

    Gerade im Legacy-Code meiner Bachelorarbeit über ein lustiges C "Feature" gestolpert. Was man doch alles in Ermangelung von Exceptions machen kann:

    1
    2
    
    /* Return value for opts_value_set() if error occurs */
    #define OPTS_SET_ERROR  (-9999)
    

    Leider kann -9999 auch ein valider Rückgabewert der Funktion sein, die diese Konstante benutzt.

    Read more
  14. printf und die Anzahl an Argumenten

    Variable Argumente in C scheinen ja auch besonders schwierig zu sein, oder man weiß es nicht, wieso printf so seltsam auf eine fehlerhafte Anzahl Argumente reagiert:

    1
    2
    3
    4
    5
    6
    7
    
    #include <stdio.h>
    int main(void) {
        int foo = 1;
        int bar = 0;
        printf("%d, %d\n", foo && bar);
        return 0;
    }
    

    Mal schnell die Berechnung einer boolschen Variable...

    Read more