[asterisk-dev] Update coding guidelines

Matthew Fredrickson creslin at digium.com
Sat Dec 30 08:15:43 MST 2006


On Dec 30, 2006, at 3:00 AM, SF Markus Elfring wrote:

> Hello,
>
> The instruction 'char *name = "data";' from the example in the section 
> "Finishing up before you submit your code" makes me suspicious.
> http://asterisk.org/developers/coding-guidelines
>
> It is against the advices from the article 
> "http://c-faq.com/decl/strlitinit.html" about the initialisation of 
> character arrays with string literals.

Why?  Not to "over analyze" the examples, but array initialization 
instead of pointer initialization is most important when you might go 
back and modify the array.  If it's not going to be modified, as in 
this example, then there should be no problem with leaving name as it 
is.  I agree, that not putting const there might make it a bit less 
literal and if that string were to be modified in that code it might 
cause problems in some architectures/compilers, in this case it would 
not since it does not modify the pointed to string.

Matthew Fredrickson



More information about the asterisk-dev mailing list