C++Guns – RoboBlog

16.11.2014

Spass mit Pointer

Filed under: Allgemein — Tags: , — Thomas @ 20:11

"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

20.10.2014

howto allocate array in C++ and pass it back to fortran

Filed under: Allgemein — Tags: , , — Thomas @ 12:10

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

Filed under: Allgemein — Tags: , , — Thomas @ 12:10

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

Filed under: Allgemein — Tags: — Thomas @ 09:09

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()

Filed under: Allgemein — Tags: , — Thomas @ 10:09

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!!

Filed under: Allgemein — Tags: , , — Thomas @ 19:09

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

Filed under: Allgemein — Tags: , , — Thomas @ 13:12

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

Filed under: Allgemein — Tags: , , , — Thomas @ 16:10

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

Filed under: Allgemein — Tags: , , — Thomas @ 09:08

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

Filed under: Allgemein — Tags: — Thomas @ 18:07

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 […]

« Newer PostsOlder Posts »

Powered by WordPress