3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-12-24 19:52:34 +01:00

Improve support for C++ functions within structs/classes

This commit is contained in:
Pragmatic Software 2015-04-09 11:03:42 -07:00
parent 1122f7ede6
commit 88f6998b12

View File

@ -312,6 +312,10 @@ sub preprocess_code {
$precode =~ s/^{(.*)}$/$1/s;
if(not $has_main and not exists $self->{options}->{'-nomain'}) {
if ($precode =~ s/^(};?)//) {
$self->{code} .= $1;
}
$self->{code} = "$prelude\n$self->{code}\n" . "int main(void) {\n$precode\n;\nreturn 0;\n}\n";
} else {
$self->{code} = "$prelude\n$self->{code}\n";