Curl namelookup_time

Adam D. Ruppe via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Nov 23 05:59:29 PST 2016


On Wednesday, 23 November 2016 at 08:24:46 UTC, Andre Pany wrote:
> 	Curl curl;
> 	curl_easy_getinfo(&curl, CurlInfo.namelookup_time, &d);


curl_easy_getinfo expects the C handle, CURL*, but you are 
passing it the D struct, Curl.

I don't understand why this even compiles, it should give an 
invalid argument type error.... let me guess, it has `alias void 
CURL`... hey look, there it is:

http://dpldocs.info/experimental-docs/source/etc.c.curl.d.html#L110

thanks, zero typechecks. It really should be an opaque struct. 
Lemme guess too, it was a typedef in C.

https://github.com/curl/curl/blob/master/include/curl/curl.h#L102

gee, typedef and alias aren't the same! This is a bug. A REALLY 
common bug.



Anyway, as to your specific instance, the D Curl struct has no 
public function to return the underlying C handle. To use the C 
functions, you'll have to create them using C functions too.


More information about the Digitalmars-d-learn mailing list