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

Goswin von Brederlow goswin-v-b at web.de
Tue Mar 18 12:14:32 CET 2014


On Sun, Mar 09, 2014 at 12:40:21AM +0100, Pieter Hintjens wrote:
> On Sat, Mar 8, 2014 at 2:11 PM, Turkey Breast <turkeybreast at yahoo.com> wrote:
> 
> > Can you give an example where adding const would break a method for existing users?
> 
> You're right. Adding const breaks code downstream, not upstream. As
> Lindley says, the problem is when it's applied inconsistently
> (annoying casting from const char * to char *).
> 
> Adding const for all char * arguments (CZMQ never modifies char *
> arguments) would be OK. It's still inconsistent with other pointer
> arguments and IMO confusing (what does it mean to pass a "const FILE
> *" argument, for instance?) But it'd be fine.
> 
> -Pieter

I would think that a "const FILE *" argument won't have its position
(seek offset) altered nor data written to it. Which would also mean
nothing is read from it (that would alter the position). So it would
be pointless to pass the argument at all.

I guess ftell() could use a "const FILE *" but it isn't declared that
way. I don't think anything is.

MfG
	Goswin



More information about the zeromq-dev mailing list