Is Var Valid in an Extern block?

BlitzMax Forums/BlitzMax Programming/Is Var Valid in an Extern block?

Gabriel(Posted 2007) [#1]
It seems to compile and work ok, but I'd like to know if that's intentional or just a happy mishap which might break or be changed.

Example :

Extern "Win32"
   Function QueryPerformanceCounter(count:Long Var)
End Extern


VS

Extern
   Function QueryPerformanceCounter(count:Long Ptr)
End Extern

Function _QueryPerformanceCounter(count:Long Var)
   QueryPerformanceCounter(VarPtr(count))
End Function


The first way is much cleaner, but I don't mind doing the second way if it's the preferred method. I'd just like to be sure which way *is* the preferred method though.


grable(Posted 2007) [#2]
Yes its valid. Because its essentially the same thing going on "under the hood".

But you have to make sure the external function ONLY accesses the correct ammount of bytes, or it will lead to unpredictable behavior.


Gabriel(Posted 2007) [#3]
Ok thanks, then I guess it's fine for the few functions I had in mind.