The reason I think correct C type is used is because in the "winscard.h" C 
header file, the expected type is LPSCARD_READERSTATE.
And , in the golang cgo code, i.e. scard_unix.go, the argument 3 is cast as 
(C.LPSCARD_READERSTATE).




*Further details (not sure if is useful): *
I found that in another C header file (pcsclite.h),  LPSCARD_READERSTATE is 
defined as:
typedef struct
{
        const char *szReader;
        void *pvUserData;
        DWORD dwCurrentState;
        DWORD dwEventState;
        DWORD cbAtr;
        unsigned char rgbAtr[MAX_ATR_SIZE];
}
SCARD_READERSTATE, *LPSCARD_READERSTATE;


And, on Windows , I could compile the code but failed on linux. 





On Tuesday, April 4, 2017 at 9:59:12 AM UTC+8, Nicholas Kho wrote:
>
> I think the correct C type is used. 
>
> refer: https://github.com/ebfe/scard/blob/master/scard_unix.go 
> Line 57:
>
> func scardGetStatusChange(ctx uintptr, timeout uint32, states 
> []scardReaderState) Error {
>        r := C.SCardGetStatusChange(C.SCARDCONTEXT(ctx), C.DWORD(timeout), 
> (C.LPSCARD_READERSTATE)(unsafe.Pointer(&states[0])), C.DWORD(len(states)))
>        return Error(r)
>
>
>
>
> On Tuesday, April 4, 2017 at 9:44:41 AM UTC+8, Ian Lance Taylor wrote:
>>
>> On Mon, Apr 3, 2017 at 5:53 PM, clashion <[email protected]> wrote: 
>> > 
>> > I tried to compile the code from https://github.com/ebfe/scard . 
>> > 
>> > Error during compilation. 
>> > 
>> > 
>> > Environment: go1.8 , linux 
>> > 
>> > 
>> > Error Message: 
>> > 
>> > 
>> > cgo-gcc-prolog:198:2: warning: passing argument 3 of 
>> ‘SCardGetStatusChange’ 
>> > from incompatible pointer type [enabled by default] 
>> > 
>> > 
>> > /usr/include/PCSC/winscard.h:64:16: note: expected 
>> ‘LPSCARD_READERSTATE’ but 
>> > argument is of type ‘struct *’ 
>> > PCSC_API LONG SCardGetStatusChange(SCARDCONTEXT hContext, 
>> > 
>> > 
>> > 
>> > Need advice how to solve this. Thanks. 
>>
>> You are using cgo code.  This error comes from the C compiler.  You 
>> need to use the correct type in your C code. 
>>
>> Ian 
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to