[ https://issues.apache.org/jira/browse/PROTON-159?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13503990#comment-13503990 ]
Andrew Stitcher edited comment on PROTON-159 at 11/26/12 7:08 PM: ------------------------------------------------------------------ In order to avoid the nuisance (unreadable) malloc casts why not introduce a macro (I think this might be one of the few places where such might be really justified). something like: #define NEW(t) ((t*) malloc(sizeof(t))) or #define NEWARRAY(t, n) ((t*) malloc((n)*sizeof(t)) or perhaps to be insufferable: #ifdef __cplusplus__ #define NEW(t) new t #define FREE(x) delete x #else #define NEW malloc(sizeof(t)) #define FREE(x) free(x) #endif I think it's just possible that using these (latter) macros and having no casts might allow the compiler to give diagnostics that it couldn't if it had casts which might be a good thing in the longer run. was (Author: astitcher): In order to avoid the nuisance (unreadable) malloc casts why not introduce a macro (I think this might be one of the few places where such might be really justified). something like: #define NEW(t) ((t*) malloc(sizeof(t))) or #define NEWARRAY(t, n) ((t*) malloc((n)*sizeof(t)) or perhaps to be insufferable: #ifdef __cplusplus__ #define NEW(t) new t #define FREE(x) delete x #else #define NEW malloc(sizeof(t)) #define FREE(x) free(x) #endif I think it's just possible that using these (latter) macros and having no casts might allow the compiler to give diagnostics that it couldn't before which might be a good thing. > port proton to C++ > ------------------ > > Key: PROTON-159 > URL: https://issues.apache.org/jira/browse/PROTON-159 > Project: Qpid Proton > Issue Type: New Feature > Components: proton-c > Affects Versions: 0.3 > Reporter: Cliff Jansen > Attachments: proton-159-0.diff, proton-159-0-partial.diff > > > Make code compile in both C99 and C++, using the gnu toolchain. This is a > necessary first step > towards a Microsoft Visual Studio port (where the compiler supports C++ but > not C99). -- 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