Archiv

Archiv für die Kategorie ‘programming’

GTK: Trayicon with effective 2 lines of C-Code

20. Juli 2009 Keine Kommentare

Because I always wanted to learn some GTK, I decided to try it first with a trayicon. And wow, it was that easy – ok, the functional factor is zero, but you’ll have a trayicon with a tooltip. And if you want more you can read the GTK documentation and extend it to the max. Mehr…

Kategorienlinux, programming Tags: , ,

git: Only commit parts of a patched file (hunk-checkin)

19. Juli 2009 Keine Kommentare

Hi, today I read Og Maciels blog entry on Planet GNOME about how he find out to not checkin a whole changed file with git but include/exclude special parts. This is something I needed in the last time much often, but never thought it exists – so with git its very easy. Mehr…

Kategorienlinux, programming Tags: ,

Subversion: Zeilen gegen Checkin sperren

17. Juli 2009 Keine Kommentare

Problem: In diesem Falle war es eine Datei die ein Define enthielt was es erlaubte gewisse Teile einer Firmware anders zu kompilieren und so diverse Tests durchzuführen. Dummerweise ist mir genau dieses eine Define beim letzten Checkin nicht aufgefallen und wurde ausversehen eingecheckt – was zwar danach dann auffiel, aber unschön ist. Mehr…

Kategorienprogramming Tags:

Sehr gutes Autotools Tutorial (englisch)

5. Juni 2009 Keine Kommentare

Nachdem ich mich jetzt doch (auch durch die Arbeit) näher mit den Autotools beschäftigen musste, habe ich nach einem guten Einstieg gesucht und bin fündig geworden. Mehr…

Kategorienprogramming Tags: ,

Vorstellung des Tools cexec

29. Mai 2009 Keine Kommentare

Wer kennt das nicht? Da hat man ein tolles Kommandozeilenprogramm mit dutzenden von Einstellmöglichkeiten und weiß nicht, welche Kombination zum besten Ergebnis führt. Mehr…

Kategorienlinux, programming Tags: ,

Semaphoren-Beispiel

24. März 2009 Keine Kommentare

Um 2007 rum habe ich mal ein Beispielprogramm geschrieben das zeigt wie man benamte Semaphoren unter Linux nutzt. Dies habe ich nun wiedergefunden, den Code ein wenig überflogen, die GPLv2 Lizenz hinzugefügt und online gestellt: Benamte Semaphoren unter Linux. Mehr…

Kategorienlinux, programming Tags: , ,

[Linux] Asynchrone Funktionsaufrufe (fastboot)

6. März 2009 Keine Kommentare

Seit dem 2.6.29-rc1 Kernel wurde angefangen, asynchrone Funktionsaufrufe zu implementieren.

Damit wird es möglich, bspw. beim Booten gleichzeitig die Erkennung der Festplatten laufen zu lassen (was leider etwas dauert) und trotzdem auch andere Geräte zu testen. Momentan laufen diese Vorgänge seriell ab. Mehr…

Kategorienlinux, programming Tags: ,

Coding C: Warning: [...] is COMMON symbol

20. November 2008 Keine Kommentare

Hi,

if you’re writing a kernel module and get the following error:

*** Warning: “symbol_name” [/path/to/module] is COMMON symbol

Than its possible that you simply forgot to mark it as static. Thanks for this fix goes to Brad Aisa from the website KernelTrap.

Bye,
Sven

Kategorienlinux, programming Tags: ,

Coding C: initialize structs in definition

11. November 2008 Keine Kommentare

Hi,


Task

We have a included struct called counter and we don’t want to assign the initial values in the main function.


Solution

source.c

#include <counters.h>

struct counter_t counter = {
    .max_value = 1234,
};

int main(void)
{
    return(0);
}

Bye,
Sven

Kategorienprogramming Tags: ,

Coding C: put timestamp into your project

6. November 2008 Keine Kommentare

Hi there,


Task

We have a Makefile, we have a C file, now we want update a timestamp whenever the C file is compiled.


Solution

Makefile

CFLAGS += -D__TIMESTAMP__=\""$(shell date +%Y/%m/%d\ %H:%M:%S)"\"

source.c

#include <stdio.h>

#ifndef __TIMESTAMP__
#define __TIMESTAMP__ "NO TIMESTAMP DEFINED"
#endif /* __TIMESTAMP__ */

int main(void)
{
    printf("my tool (TS: %s)\n", __TIMESTAMP__);
    return(0);
}


Output

~$ ./source
my tool (TS: 2008/11/06 09:55:22)

Bye,
Sven

Kategorienprogramming Tags: ,