• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Pawn] Error - compiler - functions may not return arrays of unknown size
#2
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]
stock Adrian(playerid, V, string[], max_len=sizeof(string))
{ [...]

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
that pawn always passes arrays by reference. It does this to conserve memory
and to increase performance |arrays can be large data structures and passing
them by value requires a copy of this data structure to be made, taking both
memory and time.

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.
  Reply


Messages In This Thread
RE: Error - compiler - functions may not return arrays of unknown size - by Markski - 2020-12-21, 02:53 PM

Forum Jump: