-
Notifications
You must be signed in to change notification settings - Fork 72
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
Warning on unused public variables. #71
Comments
It has just occurred to me that they can already be both |
Now the compiler won't remove public variables, even unused ones (It will still warn though if they are not marked as stock). |
I didn't actually realise it did remove unused non-stock ones. So this way does seem like the best solution thanks. |
Public variables seem like a great thing, it's interesting how SA-MP doesn't use them anywhere. Could be a good candidate for things like MAX_PLAYERS and such, especially now that they added this |
// Consume leading spaces.
#define @yN_%0\32%1 @yN_%0%1
// Consume other declarations ("final public x" etc).
//#define @yN_const%0\32%1 @yN_%0%1
#define @yN_static%0\32%1 @yN_%0%1
#define @yN_stock%0\32%1 @yN_%0%1
#define @yN_public%0\32%1 @yN_%0%1
#define final%0= %0;@yN_%0();@yN_%0()%0=
public final cMaxPlayers = GetPlayerPoolSize(); Code to call all hook OnScriptInit()
{
new
idx,
buffer;
while ((idx = AMX_GetPublicPointerPrefix(idx, buffer, _A<@yN_>)))
{
CallFunction(buffer);
// Or (faster but harder):
//#emit PUSH.C 0
//#emit LCTRL 6
//#emit ADD.C 28
//#emit PUSH.pri
//#emit LOAD.S.pri buffer
//#emit SCTRL 6
}
} |
I don't know if this is fixed as I don't have a compiler installed to test it on (sorry), but I do remember encountering it a few times in the past. Unused public functions don't have warnings because they may be used in reality by the VM (or by code modification), the same logic should apply to public variables. Currently they get a warning if they are unused, but I've had situations where I wanted them remaining. I know there is
#pragma unused
, but that's not ideal (especially in macros). An alternate solution would be to makestock public
not an invalid combination (in fact that might be the best solution for compatibility and explicitness).The text was updated successfully, but these errors were encountered: