[Unbound-users] passing string literals in C++
W.C.A. Wijngaards
wouter at nlnetlabs.nl
Tue Jun 18 08:30:31 UTC 2013
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi Ondrej,
This sort of construct is very annoying to use, because a system
header file may be used by different compilers (e.g. clang, gcc,
suncc, icc ..) and different programs may use a different standards-level.
So, right now, I have committed 'const' and hope everyone supports it.
Best regards,
Wouter
On 06/18/2013 10:04 AM, Ondřej Surý wrote:
> Hi Wouter,
>
> could you just check the availability of __cplusplus >= 199711L and
> or C99 support (either by using macro or from autoconf) and use
> something like:
>
> #ifdef C99_or_CXX11_pseudo_macro #define UB_CONST const #else
> #define UB_CONST #endif
>
> and use:
>
> int ub_function(UB_CONST char *);
>
> ?
>
>
> On Tue, Jun 18, 2013 at 9:43 AM, W.C.A. Wijngaards
> <wouter at nlnetlabs.nl <mailto:wouter at nlnetlabs.nl>> wrote:
>>
> Hi Karel,
>
> Thanks for the patch. I wanted the initial header file to use the
> least language constructs as these give rise to portability and
> parsing issues (such as types, 'pid_t'). This is why all the
> numbers are passed as 'int'. const seems to be 'C99' and posix
> :-)
>
> Best regards, Wouter
>
> On 06/17/2013 05:40 PM, Karel Slany wrote:
>> Hello,
>
>> I've recently bumped into lots of annoying messages about
>> deprecated conversion from string constant to 'char*' when I was
>> using libunbound with C++.
>
>> Apparently, functions in <unbound.h> can safely handle const
>> char* parameters, but they are declared and defined to take
>> char*. This represents no problem in C. But in C++ string
>> literals are considered const char*.
>
>> If there is no reason for declaring those functions with char*
>> arguments I would suggest to change the function prototypes to
>> take const char* arguments. The suggested patch is in the
>> attachment.
>
>> Best regards, K.
>
>
>
>> _______________________________________________ Unbound-users
>> mailing list Unbound-users at unbound.net
>> <mailto:Unbound-users at unbound.net>
>> http://unbound.nlnetlabs.nl/mailman/listinfo/unbound-users
>
>
>> _______________________________________________ Unbound-users
>> mailing list Unbound-users at unbound.net
>> <mailto:Unbound-users at unbound.net>
>> http://unbound.nlnetlabs.nl/mailman/listinfo/unbound-users
>
>
>
>
> -- Ondřej Surý <ondrej at sury.org <mailto:ondrej at sury.org>>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.13 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/
iQIcBAEBAgAGBQJRwBqnAAoJEJ9vHC1+BF+NI3IP+QEqb6O7bB10hB4uVmW41E2P
xwCthxRYpvhfNxYflBdGvxTe09KNaYTKLXLBQ3tOq1PaitWvzaxljYqecMrV3CKh
zKHVr+ySE79X2zHEYR2YGTeBVkG9OoERGJbQwYrxvGQ9eK/v14zxT9wbJPq356SX
wVcR7X8i8EKXd1DzVk8sK5Wnr2DvOBLVxJpSuQar+tZGDF3qLS0m9B+BoqkjmwpO
i5LcLIfS3qQOCWPjeTvmXBft0q3chaL3Nk1q4GvJfurdoTVENNGRylfNVtmX6stF
/eiqUGOch2Oey0u+cS+2FDamprlJQBKdHJ39jLjV98O0/dlL7sQ7Agon/27kCH7a
c+AJAdm3qbPbBfGKlpTI7FsjENY0NjpuE06KLTGJ3Y5zDIm1oowzceoGe+gYXZDi
hqFzq7hF0IdezPZDdQylasE97OeaTMIAT9KOX1FE6A0HodEL4T78fhYJv4iPYIZU
kcmDuLm5UrOweXstgglTglnvubAETCqbcvM2ba5IZh2IuTCGFMboM56utwd7SIzI
Sondzar2lerMC1e7TXt/Ypuim6Zvf9iuBpLqRcOnASotbvp6AzBJjWSlKjv6uEDq
UOWSl+L92+GAWfroi+PIvlK7mQscvrp2TPDPnDaDZz9PXuInYCZr9eaGeGCvr+7R
Ncc/Jo5NuBEURvZ14ScY
=adX3
-----END PGP SIGNATURE-----
More information about the Unbound-users
mailing list