[zeromq-dev] why do czmq methods take a char* parameter and not const char*?

Turkey Breast turkeybreast at yahoo.com
Sat Mar 8 14:11:47 CET 2014


Can you give an example where adding const would break a method for existing users?





On Saturday, March 8, 2014 8:39 AM, Pieter Hintjens <ph at imatix.com> wrote:
The lack of consts in the CZMQ API is my fault. I don't like consts in
C development; they add complexity for little (in my experience)
benefit.

Changing CZMQ now would break existing applications. I'd actually like
to remove consts where they are, to get consistency and make the APIs
more simple.

I'd just add the casts on top. It's in a wrapper and invisible to
application code. Will that work?


On Sat, Mar 8, 2014 at 4:55 AM, Turkey Breast <turkeybreast at yahoo.com> wrote:
> Not all the methods are consistent. zsockopt and zstr use const char* while zsocket, zcert and zauth use char*.
>
>
>
>
>
> On , Turkey Breast <turkeybreast at yahoo.com> wrote:
> Would you accept such a patch?
>
>
>
>
>
>
> On , Turkey Breast <turkeybreast at yahoo.com> wrote:
> My custom wrapper:
>
> https://github.com/darkwallet/czmqpp
>
> See this file:
>
> https://github.com/darkwallet/czmqpp/blob/master/src/authenticator.cpp
>
> I'm not even sure if what I'm doing is right. Does ZMQ modify those buffers at all? If so, why? Otherwise if they're just lacking const qualifiers, I'd rather not needlessly copy buffers. Would make sense to add them to czmq if possible.
>
>
>
>
>
>
> On Saturday, March 8, 2014 2:56 AM, Turkey Breast <turkeybreast at yahoo.com> wrote:
> I'm writing a c++ wrapper and this causes problems because a) string constants casting to char* is discouraged b) const char* std::string::c_str() needs a const_cast<char*> which is dodgy.
>
> Is there any chance to make some of these methods with const char* instead?
>
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev

_______________________________________________
zeromq-dev mailing list
zeromq-dev at lists.zeromq.org
http://lists.zeromq.org/mailman/listinfo/zeromq-dev




More information about the zeromq-dev mailing list