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
1 changed files with 4 additions and 0 deletions

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";