[ovs-dev] [PATCH] util: Update OVS_TYPEOF macro for Windows.

Archana Holla harchana at vmware.com
Tue Apr 7 18:10:34 UTC 2020


Thanks Ben for the review comments.
Please find my answers for the questions and could you please take a look at v2 of patch with review commented addressed.

>>Does this solve a problem?
 Yes,
  #define OBJECT_CONTAINING(POINTER, OBJECT, MEMBER) \
     ((OVS_TYPEOF(OBJECT)) (void *) \
     ((char *) (POINTER) - OBJECT_OFFSETOF(OBJECT, MEMBER)))
    
  On using ovs macro OBJECT_CONTAINING(which references OVS_TYPEOF), following compilation error is observed on windows C++ application:
  "
  error C2440: '=': cannot convert from 'void *' to 'object *'
  note: Conversion from 'void*' to pointer to non-'void' requires an explicit cast
   "
  With "decltype" keyword, this issue isn't seen as object is type casted to the right type.

>>decltype is a C++ feature.  How is it specific to Windows?
  Agree with the review comment, as decltype is a C++ construct we can use it for all C++ enabled application, addressed in patch V2.
                    
>>Please use #elif instead of introducing a nested #if...#endif.
  Yes, taken care in patch V2.

Thanks,
Archana


    On 3/19/20, 10:35 AM, "dev on behalf of Ben Pfaff" <ovs-dev-bounces at openvswitch.org on behalf of blp at ovn.org> wrote:
    
        On Thu, Mar 19, 2020 at 10:03:15AM -0700, Archana Holla via dev wrote:
        > OVS_TYPEOF macro doesn’t return the type of object for non __GNUC__ platforms.
        > Updating it for _WIN32 platforms when used from C++ code.
        > 
        > Signed-off-by: Archana Holla <harchana at vmware.com>
        > ---
        >  include/openvswitch/util.h | 4 ++++
        >  1 file changed, 4 insertions(+)
        > 
        > diff --git a/include/openvswitch/util.h b/include/openvswitch/util.h
        > index 9189e64..af7d1b0 100644
        > --- a/include/openvswitch/util.h
        > +++ b/include/openvswitch/util.h
        > @@ -86,8 +86,12 @@ OVS_NO_RETURN void ovs_assert_failure(const char *, const char *, const char *);
        >  #ifdef __GNUC__
        >  #define OVS_TYPEOF(OBJECT) typeof(OBJECT)
        >  #else
        > +#if defined (__cplusplus) && defined(_WIN32)
        > +#define OVS_TYPEOF(OBJECT) decltype(OBJECT)
        > +#else
        >  #define OVS_TYPEOF(OBJECT) void *
        >  #endif
        > +#endif
        
        Thanks for submitting a patch.
        
        Does this solve a problem?
        
        decltype is a C++ feature.  How is it specific to Windows?
        
        Please use #elif instead of introducing a nested #if...#endif.
        
        Thanks,
        
        Ben.
        _______________________________________________
        dev mailing list
        dev at openvswitch.org
        https://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fmail.openvswitch.org%2Fmailman%2Flistinfo%2Fovs-dev&data=02%7C01%7Ckumaranand%40vmware.com%7C0a5436579e8649e0f82808d7cc2be960%7Cb39138ca3cee4b4aa4d6cd83d9dd62f0%7C0%7C0%7C637202361299974072&sdata=9MXAsT5tmBCUNKNrccv0knGJe5MLeXy8RGWvpIncd9g%3D&reserved=0
        
    
    



More information about the dev mailing list