You are viewing a plain text version of this content. The canonical link for it is here.
Posted to proton@qpid.apache.org by "Cliff Jansen (JIRA)" <ji...@apache.org> on 2012/10/10 18:13:03 UTC

[jira] [Commented] (PROTON-67) Porting Issue -- Initialization with braces is not supported by Visual Studio.

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

Cliff Jansen commented on PROTON-67:
------------------------------------

I'm not sure there is any way to manage this other than as you suggest.

The downside is that the code becomes less compact and readable.  Somehow, even if fancy macros could restore the compactness, I am skeptical such macros would really make for clearer code.  So I am in favour of this approach in the absence of a better suggestion.


Note that your changes have nothing to do with "_WINDOWS".  It is all about "__cplusplus".  The same for PROTON-57.  In your future examples, it would be helpful if you kept that clear.

As a corollary, since these proposed changes are about languages and not platforms, the implication is that it is less difficult for developers to code to both C99 and C++ without having multiple development machines or rely on external CI notifications.  Linux proton developers should be able develop in gcc (C99) and sanity check with g++.  Likewise, Visual Studio proton developers should be able to develop in their IDE and sanity check with a third party C99 toolchain.  End users can just use their favourite compiler.

Just as there are C++ coding guidelines for qpid cpp

  https://cwiki.apache.org/qpid/qpid-c-documentation.html

there could be similar info for proton C: the dual compilation environment, gotchas, and guidelines.  I would volunteer to draft these pages as part of implementing PROTON-57 and PROTON-67.


                
> 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