Senior Member
Join Date: Aug 2022
Location: Colombia
|
11-17-2022
, 23:07
Re: loop entitys
|
#61
|
Quote:
Originally Posted by fysiks
Ok, so I think I have something that supports my assertion that the size of the array is determined at compile time for my method of having the sizeof as the default value of the second argument.
Here is my plugin:
PHP Code:
#include <amxmodx>
public plugin_init( ) { myFunction({1,3,5}) myFunction({1}) myFunction({2,34,334,30,340,34,0}) myFunction({2,34,334,30,340,34,0,334,30,340,34,0,334,30,340,34,0}) }
stock myFunction(myArray[], len = sizeof myArray) { #pragma unused myArray server_print("Array Size: %d", len) }
If I decompile the plugin_init() function I get this:
Code:
0x8 PROC ; public plugin_init()
0xC BREAK
0x10 BREAK
0x14 PUSH.C 0x3
0x1C PUSH.C 0x14
0x24 PUSH.C 0x8
0x2C CALL 0xA8 ; stock myFunction(myArray[],len)
0x34 BREAK
0x38 PUSH.C 0x1
0x40 PUSH.C 0x20
0x48 PUSH.C 0x8
0x50 CALL 0xA8 ; stock myFunction(myArray[],len)
0x58 BREAK
0x5C PUSH.C 0x7
0x64 PUSH.C 0x24
0x6C PUSH.C 0x8
0x74 CALL 0xA8 ; stock myFunction(myArray[],len)
0x7C BREAK
0x80 PUSH.C 0x11
0x88 PUSH.C 0x40
0x90 PUSH.C 0x8
0x98 CALL 0xA8 ; stock myFunction(myArray[],len)
0xA0 ZERO.pri
0xA4 RETN
As you can see, the first PUSH.C for each function call is the size of the array passed into the function without having to actually pass that value in the function call. This proves that the size of the array is determined at compile time, not at runtime.
If this doesn't resolve your issue with me saying that the size of the array is determine at compile time then you were arguing about something that I didn't assert.
|
eh no, what the decompiler did is show you the size of the array{ }, but when it uses size of, it is to use it inside "myfunction" server_print, so every time you use "myfunction", it will get the size of the array to use it in the server_print
As I said, the compiler will show you the data from the array { }, nothing to do when you use server_print, because there you get the size with sizeof
for example, if you try to decompile this, it will return the same data, it is not the same for the decompiler to show you the data, than for the function to obtain the maximum size of the array to be used in the server_print
PHP Code:
#include <amxmodx>
public plugin_init( ) { myFunction({1,3,5}) myFunction({1}) myFunction({2,34,334,30,340,34,0}) myFunction({2,34,334,30,340,34,0,334,30,340,34,0,334,30,340,34,0}) }
stock myFunction(myArray[]) { client_print( 0, print_chat, "%d", myArray[0] ); }
** It is one thing for it to show you the size of the array, and another is for the function to obtain the size of the array depending on which array you put **
its make me laugh that you keep trying to prove something you can't
Last edited by MrPickles; 11-17-2022 at 23:13.
|
|