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


On 05/17/2013 10:26 AM, Ian Craggs wrote:

1) char* -> const char*
2) char ** -> char* const*  (for reasons as you pointed out: http://pubs.opengroup.org/onlinepubs/009695399/functions/execve.html)
3) structures to be const (opts*  becomes const opts*)
4) char* elements of structures to be const char*

Then applying the same principles to callback functions.

Yes, that all sounds pretty good to me. Also note the use of the array notation in execv: "char *const argv[]".
That seems understandable enough.

I hadn't thought of item #4 for the structs, but it does make sense.


Here are reasons not to use const definitions instead of #defines in C:
http://stackoverflow.com/questions/2308194/shall-i-prefer-constants-over-defines/2308364#2308364


Agreed. This one may cause more trouble in C than it solves. Just be wary of naming conventions, even for "internal" headers that get pulled into an app indirectly. The pre-processor can be so destructive.

Thanks,
Frank

Back to the top