[mpich-devel] Issue with MPI_Error_string() for user-defined codes/clases
Rob Latham
robl at mcs.anl.gov
Thu Apr 24 09:59:00 CDT 2014
Hey guys this is turning into a real bikeshed.
The patch is good the way it is. There's really no good universal way
to pretty up the way C deals with strings and as Larry Baker says a lot
of it comes down to personal style preferences.
I'm just waiting for Jenkins to finish building it on all platforms
before pushing to master. something terrible happened to jenkins last
evening...
==rob
On 04/24/2014 02:11 AM, Larry Baker wrote:
> Lisandro,
>
> You are correct about the C string initializer syntax. I was not paying such close attention to your patch as to pass along to you my feelings that C mixes up integers (especially the chameleon 0) as other types. To me, "" is more communicative of the purpose. I do not have the full text of your comments about the changes you made to the original patch in front of me. I thought you mentioned changing a "" initializer to { 0 }.
>
> Though it is trivial, as I recall, the array initializer syntax also specifies that unspecified elements are initialized with zeros. If that is true, then { 0 } is not exactly the same as "", since { 0 } requires zero-initializing the entire char array whereas "" requires zero-initializing only the first element. I'm not sure an intelligent compiler would do anything different than push a block of zeros on the stack in either case.
>
> Take my comments as a friendly communication. It is not necessary for you to change the trac ticket on my behalf.
>
> Cordially,
>
> Larry Baker
> US Geological Survey
> 650-329-5608
> baker at usgs.gov
>
>
>
>
> On Apr 23, 2014, at 11:34 PM, Lisandro Dalcin wrote:
>
>> On 23 April 2014 23:11, Larry Baker <baker at usgs.gov> wrote:
>>> Lisandro,
>>>
>>> As a matter of personal taste, I prefer that empty strings be used as
>>> initializers for C strings. One of the things I dislike extremely about C
>>> (and, one of the reasons I think it is so easy in C to write bad code) is
>>> its mixing of integers and pointers and integers and chars. Even though { 0
>>> } is identical to { "" } when initializing C strings, I find the latter more
>>> informative. I know the C standard specifies that strings are terminated by
>>> the null character, which is elsewhere specified to be a byte with all bits
>>> equal to zero. However, "" is the literal empty string, whereas 0 (or '\0')
>>> is the underlying implementation of the empty string.
>>
>> Are you talking about this single line:?
>>
>> static const char empty_error_string[1] = { 0 };
>>
>> I guess you are proposing to change it to:
>>
>> static const char empty_error_string[1] = "";
>>
>> Please note {""} is an array of strings. Perhaps you meant {'\0'},
>> i.e. the null char literal?
>>
>> Please confirm your concerns were related to that single line of my
>> patch, so I can update the trac ticket.
>>
>>
>> --
>> Lisandro Dalcin
>> ---------------
>> CIMEC (UNL/CONICET)
>> Predio CONICET-Santa Fe
>> Colectora RN 168 Km 472, Paraje El Pozo
>> 3000 Santa Fe, Argentina
>> Tel: +54-342-4511594 (ext 1016)
>> Tel/Fax: +54-342-4511169
>
--
Rob Latham
Mathematics and Computer Science Division
Argonne National Lab, IL USA
More information about the devel
mailing list