Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Empty body main generates wrong output #78

Closed
namazso opened this issue Jun 29, 2022 · 1 comment
Closed

Empty body main generates wrong output #78

namazso opened this issue Jun 29, 2022 · 1 comment

Comments

@namazso
Copy link
Contributor

namazso commented Jun 29, 2022

The following code:

main()
    ;

generates the following output:

HALT 0

with main pointing at 2, so end of file. There is no RET or RETN

@compuphase
Copy link
Owner

If that code is built with default options, you will get warning 218 "old style prototypes used with optional semicolon". This hints at what is wrong: the line is seen as a C-style function prototype, not as a function implementation. So the script has a prototype for main, but not an implementation. Which is why no code is generated.

The "empty statement" in Pawn is {} (open and close curly braces). A semicolon is not an empty statement.

Though, there problems in the Pawn compiler laid bare by this issue:

  1. If you build with the "-;" option (semicolons are not optional), there is no warning at all (and no generated code).

  2. The compiler is supposed to signal the error that a script has no entry point (either "main" or any public function).

Commit eeca793 has a fix for the second point.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants