Re: [PATCH rdma-core] verbs: Fix C++ compilation break

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Oct 09, 2017 at 11:17:17AM +0300, Leon Romanovsky wrote:
> From: Leon Romanovsky <leonro@xxxxxxxxxxxx>
> 
> The commit 983f80191923 ("verbs: fix compilation error with ICC") fixed
> warning by using UINTPTR_MAX, however such change breaks compilation
> of C++ applications.
> 
> In C++ world, the UINTPTR_MAX is declared in <cstdint> and not stdint.h,
> so in order to avoid messing with various defines to decide which
> header

I don't think this statement is right. In C++ land the 'cXXX' headers
and the 'XXX.h' headers are usually the same. On my system I see
nothing that would cause stdint.h to not define the macros in C++ mode:

$ echo t.cc
#include <stdint.h>

enum {foo = UINTPTR_MAX};

$ g++-5 -c -Wall t.cc

So, what environment fails here? It should be described in the
commit message..

The best fix is something like this:

#ifdef __cplusplus
#include <limits>
#define __VERBS_ABI_IS_EXTENDED ((void *)std::numeric_limits<uintptr_t>::max())
#else
#define __VERBS_ABI_IS_EXTENDED ((void *)UINTPTR_MAX)
#endif

The static in a header file also a mistake.

Using <cstdint> is a bit risky since it is a c++11 header and may not
be in some of the older distros we still support.

Jason
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux