1. Phix: A Error Message i do not understand.
- Posted by andreasWagner in February
- 493 views
Hallo
I am trying to adapt an older library to Phix and Windows 64bit
I don't know how to deal with the following message.
D:\devpool\phix\builtins\cffi.e:234 unknown size [ --> see D:\devpool\projects\ardulink\ex.err Press Enter...
--REF: http://msdn.microsoft.com/en-us/library/aa363858(VS.85).aspx --constant iCreateFile = define_c_func(kernel,"CreateFileA",{C_INT,C_INT,C_INT,C_INT,C_INT,C_INT,C_INT},C_INT) tStr=""" HANDLE CreateFileA( [in] LPCSTR lpFileName, [in] DWORD dwDesiredAccess, [in] DWORD dwShareMode, [in, optional] LPSECURITY_ATTRIBUTES lpSecurityAttributes, [in] DWORD dwCreationDisposition, [in] DWORD dwFlagsAndAttributes, [in, optional] HANDLE hTemplateFile ); """ --LPSECURITY_ATTRIBUTES replaced with LPVOID (does not help) remove 'optional' also not set_unicode(0) constant iCreateFile=define_cffi_func(kernel,tStr)
I have no idea anymore (i also don't understand the inner function of cffi.e)
THe sourcefile is here:https://github.com/andizk4kx/ArduLink/blob/main/serial.ew
The ex.err is here:https://github.com/andizk4kx/ArduLink/blob/main/ex.err
Thank you for any help in advance
Andreas
Edit:
I've had this problem before, I just forgot about it.I am firmly convinced that my brain is working against me (at least partially)
Perhaps the error message could still be made a little more meaningful.
e.g. errors when interpreting : tStr line xy
This works for me:
HANDLE CreateFileA( _in_ LPCSTR lpFileName, _in_ DWORD dwDesiredAccess, _in_ DWORD dwShareMode, _in_ LPVOID lpSecurityAttributes, _in_ DWORD dwCreationDisposition, _in_ DWORD dwFlagsAndAttributes, _in_ HANDLE hTemplateFile ); """ --LPSECURITY_ATTRIBUTES replaced with LPVOID remove 'optional' constant iCreateFile=define_cffi_func(kernel,tStr)
Andreas
2. Re: Phix: A Error Message i do not understand.
- Posted by petelomax in February
- 456 views
[in] LPCSTR lpFileName, _in_ LPCSTR lpFileName,
Oooh! Never seen that style before, but yep, that's what MSDN is using these days.
Best I can tell they ripped out "_in_" in 2020 (weird "SAL" which I ignored anyway)
and now they've stuck this in. I guess it follows the traditional pattern for C++:
Nevermind, easily fixable:
if match("_",mtype)=1 then -- "_In_", "_Inout_opt_", "_Out_" etc mtype = stoken()
elsif equal(mtype,"[") then -- "[in]", "[in, optional]", etc while not equal(mtype,"]") do mtype = stoken() end while mtype = stoken()
(Methinks improving that error message is best left for a rainy day....)
Good catch, thanks.
PS gratuitous link for the 2020 reference: https://stackoverflow.com/questions/63105593/why-did-msdn-remove-in-co-from-the-winapi-documentation
PPS erm, make that 2019: https://hero.handmade.network/forums/code-discussion/t/6907-msdn_windows_api_syntax_changes
3. Re: Phix: A Error Message i do not understand.
- Posted by andreasWagner in February
- 448 views
(Methinks improving that error message is best left for a rainy day....)
Good catch, thanks.
PS gratuitous link for the 2020 reference: https://stackoverflow.com/questions/63105593/why-did-msdn-remove-in-co-from-the-winapi-documentation
PPS erm, make that 2019: https://hero.handmade.network/forums/code-discussion/t/6907-msdn_windows_api_syntax_changes
Thank you, your patch works out of the box.
i don't want to be annoying but here is maybe one more for a rainy day
tStr=""" BOOL WINAPI TransmitCommChar( _In_ HANDLE hFile, _In_ char cChar ); """ -- char is not working set_unicode(0) constant iTransmitCommChar=define_cffi_func(kernel,tStr)
D:\devpool\phix\builtins\cffi.e:1311 in function define_c() index 0 out of bounds, reading sequence length 6 lib = 1.407099524e+14 cdef = "BOOL WINAPI TransmitCommChar(\n _In_ HANDLE hFile,\n _In_ char cChar\n); \n" func = 1 machine = 64 name = "TransmitCommChar" mtype = "char" substruct = 0 size = 1 align = 1 signed = 1 return_type = 16777220 ptype = 33554440 Global & Local Variables --> see D:\devpool\projects\ardulink\ex.err Press Enter...by the way, here in germany, it feels like it's been raining since october last year, interrupted only by a few days of snow.
Thank you
Andreas
Edit:
Maybe I should pray for a rainy summer
D:\devpool\phix\builtins\cffi.e:234 bitfields are not (yet) supported
4. Re: Phix: A Error Message i do not understand.
- Posted by petelomax in February
- 454 views
i don't want to be annoying but here is maybe one more for a rainy day
--/* Some of these may need adding: -- initialConstant("C_CHAR", #01000001) -- initialConstant("C_BYTE", #01000001)
So about 8 lines above that, as the new first entry, add
{{1,1},C_BYTE}, -- (=== C_CHAR)
Thanks again, all good stuff.
D:\devpool\phix\builtins\cffi.e:234 bitfields are not (yet) supported
That would be significantly trickier. What struct[?] was that?
I suspect it would be much easier to replace the definition with a byte/word/dword,
and extract all 8/16/32 bits, modify that, then put them all back, iyswim.
- A new pair of get_bit()/set_bit() routines ought to be fairly straightforward,
but I'd want to be able to prove to myself they were doing the right thing.
(such would obviously be better for bitfields other than 1/2/4 bytes)
5. Re: Phix: A Error Message i do not understand.
- Posted by andreasWagner in February
- 406 views
So about 8 lines above that, as the new first entry, add
{{1,1},C_BYTE}, -- (=== C_CHAR)
Thank you, this is working.
D:\devpool\phix\builtins\cffi.e:234 bitfields are not (yet) supported
That would be significantly trickier. What struct[?] was that?
This one:https://learn.microsoft.com/de-de/windows/win32/api/winbase/ns-winbase-dcb
It's also back in serial.ew (as comment ) line28
I suspect it would be much easier to replace the definition with a byte/word/dword,
and extract all 8/16/32 bits, modify that, then put them all back, iyswim.
Yes, you are correct.
- A new pair of get_bit()/set_bit() routines ought to be fairly straightforward,
but I'd want to be able to prove to myself they were doing the right thing.
(such would obviously be better for bitfields other than 1/2/4 bytes)
So there is no hurry to do anything. But it would be cool to have something like get_bit()/set_bit().
But today is nice weather (no, it's just not raining). I'm going outside.
Again, Thank you
Andreas
6. Re: Phix: A Error Message i do not understand.
- Posted by petelomax in February
- 378 views
Thanks, that's actually a pretty decent example, with fBinary..fDummy2 occupying all 32 bits of a single dword.
I'm half-tempted to give it a go, but instead just added a note to the docs: http://phix.x10.mx/docs/html/define_struct.htm#bitfields
It's also back in serial.ew (as comment ) line28
Not actually mine, did you mean http://phix.x10.mx/pmwiki/pmwiki.php?n=Main.WindowsSerialPortAccess (which for me references said on lines 95 and 222)
7. Re: Phix: A Error Message i do not understand.
- Posted by andreasWagner in February
- 382 views
Hallo
It's also back in serial.ew (as comment ) line28
Not actually mine, did you mean http://phix.x10.mx/pmwiki/pmwiki.php?n=Main.WindowsSerialPortAccess (which for me references said on lines 95 and 222) [/quote]
I am trying to adapt this library to Phix and Windows 64bit
This copy (the one i referenced in the first post), the one I'am working on:
THe sourcefile is here:https://github.com/andizk4kx/ArduLink/blob/main/serial.ew
BTW: I have already changed more than would have been necessary
Again, Thank you for the quick response
Andreas