Last active
August 29, 2015 14:00
-
-
Save robryk/2de6e4abf66d9a01b7f2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
program a; | |
{$L ac.o} | |
{$LinkLib c} | |
{$LinkLib gcc_s} | |
procedure install_foo;cdecl;external; | |
begin | |
install_foo; | |
end. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdlib.h> | |
#include <stdio.h> | |
void __attribute__ ((destructor)) stuff3() { | |
printf("baz\n"); | |
} | |
void __attribute__ ((constructor)) stuff2() { | |
printf("bar\n"); | |
} | |
void stuff() { | |
printf("foo\n"); | |
} | |
void install_foo() { | |
atexit(&stuff); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
program a; | |
{$L bc.o} | |
{$LinkLib c} | |
{$LinkLib stdc++} | |
{$LinkLib gcc_s} | |
uses initc; | |
begin | |
end. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cstdio> | |
bool do_foo() { | |
printf("foo\n"); | |
return true; | |
} | |
static bool foo = do_foo(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gcc -c ac.c | |
fpc a.pas | |
Free Pascal Compiler version 2.6.4 [2014/03/12] for x86_64 | |
Copyright (c) 1993-2014 by Florian Klaempfl and others | |
Target OS: Linux for x86-64 | |
Compiling a.pas | |
Linking a | |
/usr/bin/ld: warning: link.res contains output sections; did you forget -T? | |
11 lines compiled, 0.1 sec | |
./a | |
foo | |
baz | |
g++ -c bc.cpp | |
fpc b.pas | |
Free Pascal Compiler version 2.6.4 [2014/03/12] for x86_64 | |
Copyright (c) 1993-2014 by Florian Klaempfl and others | |
Target OS: Linux for x86-64 | |
Compiling b.pas | |
Linking b | |
/usr/bin/ld: warning: link.res contains output sections; did you forget -T? | |
11 lines compiled, 0.1 sec | |
./b | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
set -v | |
gcc -c ac.c | |
fpc a.pas | |
./a | |
g++ -c bc.cpp | |
fpc b.pas | |
./b | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment