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

ignored constant sym param #159

Closed
Dayvison opened this issue Mar 15, 2017 · 2 comments
Closed

ignored constant sym param #159

Dayvison opened this issue Mar 15, 2017 · 2 comments

Comments

@Dayvison
Copy link

Dayvison commented Mar 15, 2017

Code:

#if defined a
	#error "a"
#else
	#error "b"
#endif
main() { }

Command used:
pawncc.exe m.pwn a=1

Zeex compiler:

Pawn compiler 3.10.2                    Copyright (c) 1997-2006, ITB CompuPhase

m.pwn(4) : fatal error 111: user error: "b"


Compilation aborted.


1 Error.

Original compiler:

m.pwn(2) : fatal error 111: user error: "a"


Compilation aborted.

Pawn compiler 3.2.3664                  Copyright (c) 1997-2017, ITB CompuPhase


1 Error.
@YashasSamaga
Copy link
Member

YashasSamaga commented Mar 24, 2017

What's happening?

  1. The compiler parses the compiler options at the very beginning.
  2. The compiler deletes the constants given as compiler options before it parses.

So any constants which were added when the compiler options were parsed are deleted.

While it does not delete the predefined constants (constants with flagPREDEF), it deletes the rest (which includes constants passed to the compiler as arguments).

https://github.com/Zeex/pawn/blob/00f21e67d543bf6eeda5943a8891caeeb0a991d2/SOURCE/compiler/sc1.c#L1155

add_constant(str,i,sGLOBAL,0); should be add_builtin_constant(str,i,sGLOBAL,0); for constants given through compiler arguments?

@Southclaws
Copy link
Collaborator

+1 I use this and I only found about this bug today, it would really screw up my build process if I migrated to this compiler (which I wanted to for SS).

@YashasSamaga could you submit a pull request with the proposed fix?

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

4 participants