pawn-lang / compiler

Pawn compiler for SA-MP with bug fixes and new features - runs on Windows, Linux, macOS
Other
301 stars 71 forks source link

FIX: Set actual default values in usage() #714

Closed ghost closed 1 year ago

ghost commented 2 years ago

What this PR does / why we need it: Changes default values in usage() to default values instead of current values. NOTE: I simply ran pawncc without arguments (and making sure no alias was set), used given values from there. Looking at initglobals() this could still not be 100% accurate:

  #if AMX_COMPACTMARGIN > 2
    sc_compress=TRUE;    /* compress output bytecodes */
  #else
    sc_compress=FALSE;
  #endif

AMX_COMPACTMARGIN hould be 64 by default, no idea what that does any futher (not that much into AMX). Seems like it should be fine though.

Which issue(s) this PR fixes: None opened

What kind of pull this is:

Additional Documentation: N/A

Daniel-Cortez commented 2 years ago

Firstly, you should've created an issue to report the problem in the first place (which, if I understand it correctly, is that command line arguments overwrite default values before the compiler prints them in function usage(), e.g. if we invoke the compiler as pawncc -O0 it will print default: -O0 for option -O, while it's supposed to print -O1).

Secondly, hardcoding those values at the place of their use is a bad practice. If we'll need to change them for one reason or another, we'll have to modify them not only in function resetglobals(), but also in usage(). A good solution should involve keeping those values in one place, e.g.:

// somewhere at the top of sc1.c
#define sDEFAULT_DEBUG_LEVEL sCHKBOUNDS

// in initglobals():
sc_debug=sDEFAULT_DEBUG_LEVEL;

// in about():
pc_printf(" -d<num> debugging level (default=-d%d)\n", sDEFAULT_DEBUG_LEVEL);