[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 - How to pass NULL argument to C function

How to pass NULL argument to C function

Q&A's, tips, howto's

How to pass NULL argument to C function

Postby csfreebird » Sun Dec 07, 2014 3:56 pm

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

Re: How to pass NULL argument to C function

Postby ryuo » Sun Dec 07, 2014 9:48 pm

To pass a NULL pointer, you would have to use its integer value, 0. But there is another issue. You are trying to map a variadic C function. These may not be usable from the newLISP FFI API, but it appears libFFI supports them. The newLISP documentation doesn't appear to mention anything about variadic functions, so I think it is reasonable to conclude that they are not supported. However, only Lutz probably knows for sure.

The problem is that variadic C functions may or may not be callable in the same way as a regular C function. To the best of my knowledge, this is an "implementation detail" and therefore may not be portable. In other words, your current function import may not work on other newLISP platforms, if it even works on the current platform.

If I am correct, then here are some ideas that may help you work around this potential issue: use an alternative normal C function that can achieve the same results or write shared library code to wrap the variadic function call within a normal C function.
ryuo
 
Posts: 43
Joined: Wed May 21, 2014 4:40 pm

Re: How to pass NULL argument to C function

Postby Lutz » Sun Dec 07, 2014 11:23 pm

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

Re: How to pass NULL argument to C function

Postby csfreebird » Mon Dec 08, 2014 5:31 pm

Thanks. I know to pass 0 as NULL argument now and how to use variadic function.
I still have some questions when developing mongodb.lsp based on mongodb c driver.
Will ask them in other threads.
csfreebird
 
Posts: 107
Joined: Tue Jan 15, 2013 11:54 am
Location: China, Beijing


Return to newLISP in the real world

Who is online

Users browsing this forum: No registered users and 2 guests

cron