[SA-MP plugins] static functions
#1

Example function copied from Pawn Impementer's Guide
Код:
static cell n_sin(AMX *amx, const cell *params)
{
  float r = sin( amx_ctof(params[1]) );
  return ftoc®;
}
Everyting is quite clear here. Except for the fact, that function is declared static! Not all of them are declared using this keyword however. Can anyone explain, what's the point using it?
Reply
#2

This function can be used only in the file that they were declared.

So if you put include after that function for a file it won't work because this function is made for the file that it's in only.

I hope I helped any feedback would be appreciated.
Reply
#3

Let's say I introduce two static functions with the same name in a header file and in a source file. They both do different stuff though. You mean these would not interfere somehow? Code would compile well?
Reply
#4

Yes I believe. By the way, if you have big codes that contain complex scripting then use static to not have human errors. For example: I put "static ninja(playerid, whatever) in a file in another file that is already included I can use static ninja in another structure.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)