Login
Newsletter
Werbung

Thema: Gewinnspiel: Fünf Bücher »C-HowTo« zu gewinnen

1 Kommentar(e) || Alle anzeigen ||  RSS
Kommentare von Lesern spiegeln nicht unbedingt die Meinung der Redaktion wider.
0
Von Anonymous am Mo, 31. Januar 2011 um 16:00 #

Von mir aus... hier das C-Programm:

#include <stdio.h>
#define FOO 42
static void go() {
printf("%d\n", FOO);
}
int main() {
go();
return 0;
}

Kompiliert mit gcc -O2 -S ergibt das
.file "test.c"
.section .rodata.str1.1,"aMS",@progbits,1
.LC0:
.string "%d\n"
.text
.p2align 4,,15
.globl main
.type main, @function
main:
pushl %ebp
movl %esp, %ebp
andl $-16, %esp
subl $16, %esp
movl $42, 4(%esp)
movl $.LC0, (%esp)
call printf
xorl %eax, %eax
leave
ret
.size main, .-main
.ident "GCC: (Debian 4.4.5-10) 4.4.5"
.section .note.GNU-stack,"",@progbits


Und nun das C++-Programm:
#include <cstdio>
namespace {
class dummy {
static const int FOO = 42;
public:
static void go() {
std::printf("%d\n", FOO);
};
};
}
int main() {
dummy::go();
}

Kompiliert mit g++ -O2 -S -fno-exceptions ergibt das
.file "test.cc"
.section .rodata.str1.1,"aMS",@progbits,1
.LC0:
.string "%d\n"
.text
.p2align 4,,15
.globl main
.type main, @function
main:
pushl %ebp
movl %esp, %ebp
andl $-16, %esp
subl $16, %esp
movl $42, 4(%esp)
movl $.LC0, (%esp)
call printf
xorl %eax, %eax
leave
ret
.size main, .-main
.ident "GCC: (Debian 4.4.5-10) 4.4.5"
.section .note.GNU-stack,"",@progbits


Der Code ist auf's Komma genau derselbe.

[
| Versenden | Drucken ]
Pro-Linux
Pro-Linux @Facebook
Neue Nachrichten
Werbung