[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4762: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4764: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4765: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4766: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
newlispfanclub.alh.net • View topic - Don't know how to pass a pointer of structure to C function

Don't know how to pass a pointer of structure to C function

Q&A's, tips, howto's

Don't know how to pass a pointer of structure to C function

Postby csfreebird » Thu May 15, 2014 3:49 pm

csfreebird
 
Posts: 107
Joined: Tue Jan 15, 2013 11:54 am
Location: China, Beijing

Re: Don't know how to pass a pointer of structure to C funct

Postby ryuo » Wed May 21, 2014 4:53 pm

Although I am new to newlisp, I have experience with C. I believe the problem you are having is that the function you are trying to call expects a "pointer" to the struct. The struct must be allocated somewhere in memory first, and then you need to feed the address of the instance of that struct to the function. You probably need to retrieve the address via the 'address' function, documented here:

http://www.newlisp.org/downloads/newlis ... ml#address

It only gives examples with strings and integers, but it would be weird if it didn't support other types. This may or may not solve the problem, as it could be something else to do with lisp. But, I just noticed that it looked like you were trying to pass the struct and not a pointer to the struct.

Edit:

I also noticed upon a second look that you don't post code that converts the C struct. A look into the API reveals a struct function:

http://www.newlisp.org/downloads/newlis ... tml#struct

I think you also need to do this in addition to getting the address for the struct.
ryuo
 
Posts: 43
Joined: Wed May 21, 2014 4:40 pm

Re: Don't know how to pass a pointer of structure to C funct

Postby csfreebird » Sat May 24, 2014 5:16 am

csfreebird
 
Posts: 107
Joined: Tue Jan 15, 2013 11:54 am
Location: China, Beijing

Re: Don't know how to pass a pointer of structure to C funct

Postby ryuo » Sat May 24, 2014 8:57 pm

ryuo
 
Posts: 43
Joined: Wed May 21, 2014 4:40 pm

Re: Don't know how to pass a pointer of structure to C funct

Postby Lutz » Sun May 25, 2014 6:58 am

Lutz
 
Posts: 5279
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California


Return to newLISP in the real world

Who is online

Users browsing this forum: No registered users and 1 guest

cron