Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [paho-dev] Using C++ with the Paho C client library

Specifically, some objections to using const (in C).

1) I can't pass a char** to a const char** or a const char * const * without a cast. Adding casts requires changing programs, apart from the principle of adding what seem unnecessary casts. See:

int f(const char * const * c)
{
    c = 0;
    c[1] = 0;
    c[0][0] = 1;
}


int main(int argc, char** argv)
{
    f(argv); /* cast needed - why? */
    return 0;
}

2) For char** topic, do you want const char** or const char* const *? Presumably the latter, which I think is verging on the hard to understand.

Ian


On 16/05/13 23:00, Ian Craggs wrote:
I agree about the timing. The question would be when to fit in the work of:

1) which of the parameters, elements of structures, etc to apply the change to. Could be >50 parameters and elements to review.

2) whether to apply the change to #defines as well. I seem to remember starting with const definitions, running into problems again, and hence deciding to go with old-fashioned #defines. This would seem to be more a C++ concern, and can be fixed in a C++ header anyway.

3) testing the implications on all main platform combinations, including back to gcc 3.8 and older MS C/C++ compilers, for effects and backward compatilbility.

Ian



On 16/05/13 22:15, Roger Light wrote:
Hi,

(2) Observe proper const-ness for pointer parameters if there is no intent
in updating the item, particularly "const char*" for "char*"

DLLExport int MQTTAsync_create(MQTTAsync* handle,
         const char* serverURI, const char* clientId, ...
It occurs to me that if this change is going to be made (and I'd agree
with it) it ought to be done sooner rather than later because it
represents an API change. Once there's a proper release and it is
being packaged it's a lot more awkward to change.

Cheers,

Roger
_______________________________________________
paho-dev mailing list
paho-dev@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/paho-dev


_______________________________________________
paho-dev mailing list
paho-dev@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/paho-dev



Back to the top