"man kann sich so derbe den kopf weg schiessen damit" int global; char *func() { return (char*)&global; } int main() { char *x = func(); int *RocketPtr = (int*)x; *RocketPtr = 1337; cout
16.11.2014
20.10.2014
howto allocate array in C++ and pass it back to fortran
test.cpp #include < stdlib.h > // fortran can only call C routines extern "C" { // we need the address of the fortran pointer thus a pointer of a pointer. void myC_func(int **arr) { // we cannot use new() here because fortran deallocate() use free() instead of delete[] *arr = (int*) malloc(12*sizeof(int)); for(int i=0; i […]
07.10.2014
Faster Code – Part 6 – Sprungvorhersage - anschaulich
Sehr schöne anschauliche Erklärung: http://stackoverflow.com/questions/11227809/why-is-processing-a-sorted-array-faster-than-an-unsorted-array
12.09.2014
I can feel segfaults
int main() { const char *a = "I can feel segfaults"; printf("%c\n", (char*) * (char*) * (a+strlen(a))); return 0; }
04.09.2014
virtual inheritance and sizeof()
Folgender Code: #include < iostream > #include < stdint.h > using namespace std; class Base { public: int32_t a; }; class Derived : public Base { public: int32_t b; }; class VirtualDerived : virtual public Base { public: int32_t c; }; int main() { cout
03.09.2014
Fortran is DEAD!!
Leute, ist sag es schon die ganze Zeit: Fortran ist eine tote Sprache. Und damit meine ich nicht nur diese verbuggten Compiler. Oder dass es ewig braucht bis man ein neues Feature vom Compiler unterstützt wird. Im Fortran 2003 Standard sind zwar schön viele OO Ansatze festgelegt, aber ich kenne kein Compiler der den Standard […]
08.12.2012
Mehrere Object Files zusammenfassen
Für eine .a lib: ar -ru test.a 1.o 2.o Für eine große .o Datei: ld -r objectList -o destObject
06.10.2012
Installing gcc, g++ and gfortran 4.8 from source
First read http://gcc.gnu.org/install/ Make sure you have all Prerequisites installed! Download all files to ~/opt/downloads Install all packages to ~/opt/ Download gcc 4.8 from ftp://ftp.gwdg.de/pub/misc/gcc/snapshots/LATEST-4.8/ and unpack it. wget ftp://ftp.gwdg.de/pub/misc/gcc/snapshots/LATEST-4.8/gcc-4.8-20120930.tar.bz2 tar xjf gcc-4.8-20120930.tar.bz2 cd gcc-4.8-20120930 Download several necessary librarys into the gcc source directory and unpack them. They will be built together with GCC. wget […]
23.08.2012
Farbige Konsolenausgabe
Farbe in der Konsole ist nicht schwer. Beispiele in C und Fortran: #include < unistd.h > void resetFont() { if (isatty (fileno (stdout))) std::cout
31.07.2012
fucking C Part 2
Part 1 int array[2][2]={{0,1}, {2,3}}; printf("element: %i\n", *( *( array + (0,1)) + (0,1) ) ) ; kater@ktux:~$ bin/gcc/bin/gcc -Wall test.c test.c: In function ‘main’: test.c:87:43: warning: left-hand operand of comma expression has no effect [-Wunused-value] test.c:87:52: warning: left-hand operand of comma expression has no effect [-Wunused-value] Welche Zahl wird ausgegeben? 0, 1, 2 oder […]