Constant Expression
Why doesn't this work
Code:
where Code:
Gives me this error Code:
error 008: must be a constant expression; assumed zeroBONUS QUESTION: Can you use any kind of pointer in Pawn, exept for the pass by reference when working with functions? |
Re: Constant Expression
Well, the error message basically explains it:
You may only use constant expressions for such initializer lists. i.e no "normal" variables. Either use all constants, or first declare the array and then assign the non-constant things separately. Pointers... well, you could hack together some semi-pointers by mixing up byref and byval with callfunc stuff. Code:
I just hacked this together and haven't tested it (only compile), but you get the idea. So it may not work, maybe I made typos, maybe the comma operator is broken (i doubt that though), whatever. But you get the idea ;) Of course, this is neither very useful nor effective performance-wise (actually, it'll have pretty awful performance) EDIT: In fact, it turns out that BAIL has added get_addr_val, get_var_addr, set_addr_val to core. You might want to check them out in the funcwiki. Still I'm leaving my code here because I had some good fun writing it. |
Thanks PM
I was trying to improve performance with a pointer to avoid copying a 256 char string. I will certainly look for the functions you mentioned. But first I'll have a good night of sleep :D |
Quote:
as arguments, arrays are always passed by reference automatically maybe you want to share it between plugins? that wouldn't work even with this "pointer" stuff because these are really addresses into the plugin's memory.. Hmm, more info please :) |
I'm the one that asked for the address hacking tools XD
The best method for doing this though, would be MemHack, as you can get the actual address. |
| All times are GMT -4. The time now is 05:01. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.