[Pawn] Error - compiler - functions may not return arrays of unknown size - Printable Version + open.mp forum (https://forum.open.mp) -- Forum: SA-MP (https://forum.open.mp/forumdisplay.php?fid=3) --- Forum: Pawn Scripting (https://forum.open.mp/forumdisplay.php?fid=10) --- Thread: [Pawn] Error - compiler - functions may not return arrays of unknown size (/showthread.php?tid=1446) |
Error - compiler - functions may not return arrays of unknown size - vandiesel45 - 2020-12-21 I have this errors with the latest pawn compiler Code: error 092: functions may not return arrays of unknown size (symbol "Adrian") that's de line: Code: Adrian(B, item, 0); this is stock: Code: stock Adrian(playerid, string[], V) RE: Error - compiler - functions may not return arrays of unknown size - Markski - 2020-12-21 There's a few things wrong here: - You're receiving a string without knowing it's size. The compiler complains because you're then trying to return this same string. The problem above can be solved by simply setting the size of the string being received. Code: stock Adrian(playerid, string[SIZE], V) If the size of the string is going to vary, you could do something like this Code: [CODE] However, there's a higher concept problem here: You don't need to return the string in the first place. Arrays in Pawn are always passed by reference. From page 18 of the Pawn Language document: Quote:When you are working with strings, or arrays in general, note This means that the string which is being passed is going to be modified by the function receiving it. You don't need to explicitly return it. RE: Error - compiler - functions may not return arrays of unknown size - vandiesel45 - 2020-12-21 (2020-12-21, 02:53 PM)Markski Wrote: There's a few things wrong here: i do exactly but i have two errors: error 047: array sizes do not match, or destination array is too small la: OnPlayerLogin -?Adrian(playerid, password, PlayerInfo[playerid][pLoserLevel]); la OnPlayerRegister -?Adrian(playerid, password, 0); Quote:stock Adrian(playerid, string[33], V) RE: Error - compiler - functions may not return arrays of unknown size - Markski - 2020-12-21 Because the string you're giving it isn't the same size as the string you're receiving. They should both be the same size. Still, I suggest you read my whole post to understand why you don't need to return the string in the first place. |