Re: curl_easy_setopt type checking for C++
Date: Tue, 10 Dec 2019 15:04:10 +0100 (CET)
On Mon, 9 Dec 2019, Jeff Mears via curl-library wrote:
> curl_easy_setopt and curl_multi_setopt don't currently have a C++
> implementation that enforces type checking. In C, it uses GCC extensions to
> do this type checking.
Right, because there's no native "real" C way to do it.
> curl_easy_setopt(easy, CURLOPT_NOSIGNAL, 1);
>
> In C, this is broken.
Yes; In C on platforms where long and int are sized differently...
> In C++, there are essentially two ways to do this. Should it cause a
> compiler error, or automatically allow this to work properly by converting
> to long first?
I don't know what methods you speak of so I can't tell if they are completely
equal in terms of readability, maintainability etc.
If there's a downside with automatically converting ints to longs in those two
functions, it is that it will create more code out there for people to copy
and paste from that will generate errors and pain if that C++ version would
look exactly the same as the C version but in that imaginary C++ version we
can pass in an int and it will be fine we cannot in the C version...
So, I lean towards erroring on wrong type.
-- / daniel.haxx.se | Get the best commercial curl support there is - from me | Private help, bug fixes, support, ports, new features | https://www.wolfssl.com/contact/ ------------------------------------------------------------------- Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library Etiquette: https://curl.haxx.se/mail/etiquette.htmlReceived on 2019-12-10