I get casting errors when passing a struct by reference. Passing a pointer to a buffer works fine. The function getstuff() is actually libusb_claim_interface() with irrelevant parts removed. I am trying to get a chunk of data back from a USB device plugged into a Linux machine. The data comes in according to this struct: However, the code I was
Tag: casting
C code about pointers
I’ve got this simple code that plays with pointers taken from Jon Eriksen’s book that I’m trying to compile but gcc gives me warnings in compilation and segmentation fault (core dumped) when I run it. Output: Answer This program is wrong, and the advice given in the book is obviously wrong, too. A pointer can be converted to an integer
C assembler function casting
I came across this piece of code (for the whole program see this page, see the program named “srop.c”). My question is regarding how func is used in the main method. I have only kept the code which I thought could be related. It is the line *ret = (int)func +4; that confuses me. There are three questions I have