[ 
https://issues.apache.org/jira/browse/PROTON-67?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13473406#comment-13473406
 ] 

Andrew Stitcher commented on PROTON-67:
---------------------------------------

Is it worth pointing out that regular brace initialisation of structures has 
been in C for a very long time and is certainly supported by Visual Studio c 
and c++.

So it's only necessary to change 
    pn_atoms_t latoms = {.size=data->size + data->extras, .start=atoms}; 
into
    pn_atoms_t latoms = {data->size + data->extras, atoms};

Of course for many other structs it won't be so simple and will require setting 
default values for uninitialised members in the middle of initialised values. 
Also the code will no longer be as clear or safe.

                
> Porting Issue -- Initialization with braces is not supported by Visual Studio.
> ------------------------------------------------------------------------------
>
>                 Key: PROTON-67
>                 URL: https://issues.apache.org/jira/browse/PROTON-67
>             Project: Qpid Proton
>          Issue Type: Improvement
>          Components: proton-c
>         Environment: Windows using Visual Studio 2010
>            Reporter: Mary hinton
>              Labels: build
>
> In the Windows port, I used ifdef(s)  for the initializations to keep the 
> current code for Linux, and added code to compile in Visual Studio. If there 
> is no objection, maybe we could replace the current initialization code with 
> the Visual Studio code and remove the #ifdef(s). 
> Here's some examples:
> Eample1
> ssize_t pn_data_encode(pn_data_t *data, char *bytes, size_t size)
>  {
>  #ifndef _WINDOWS
>    pn_atoms_t latoms = {.size=data->size + data->extras, .start=atoms};
>  #else
>   pn_atoms_t latoms;
>    latoms.size = data->size + data->extras;
>    latoms.start = atoms;
>  #endif
>  
> --------------------
>  Example 2
>  
> #ifndef _WINDOWS 
>   return (pn_bytes_t) {size, start};
>  #else
>  pn_bytes_t pnBytes;
>  pnBytes.size = size;
>  pnBytes.start= start;
>  return pnBytes;
>  #endif
>  --------------------
>  Example 3
>  
> pn_do_transfer()
>  
> #ifndef _WINDOWS 
>     delivery = pn_delivery(link, pn_dtag(tag.start, tag.size));
>  #else
>  pn_delivery_tag_t delivt;
>  delivt.bytes = tag.start;
>  delivt.size = tag.size;
>  delivery = pn_delivery(link, delivt);
>  #endif

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to