Skip to content

Commit f36a0d8

Browse files
authored
Refactor attribute detection (#3493)
Refactor attribute detection
2 parents 39adbb7 + 5b49c92 commit f36a0d8

File tree

3 files changed

+14
-15
lines changed

3 files changed

+14
-15
lines changed

common/include/pcl/pcl_macros.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -365,22 +365,22 @@ aligned_free (void* ptr)
365365
*
366366
* \ingroup common
367367
*/
368-
#if __has_cpp_attribute(fallthrough) && !(defined(__clang__) && __cplusplus < 201703L)
368+
#if (__cplusplus >= 201703L) || (defined(_MSC_VER) && (_MSC_VER >= 1910) && (_MSVC_LANG >= 201703L))
369369
#define PCL_FALLTHROUGH [[fallthrough]];
370370
#elif defined(__clang__)
371371
#define PCL_FALLTHROUGH [[clang::fallthrough]];
372-
#elif defined(__GNUC__)
373-
#if __GNUC__ >= 7
374-
#define PCL_FALLTHROUGH [[gnu::fallthrough]];
375-
#else
376-
#define PCL_FALLTHROUGH ;
377-
#endif
372+
#elif defined(__GNUC__) && (__GNUC__ >= 7)
373+
#define PCL_FALLTHROUGH [[gnu::fallthrough]];
378374
#else
379-
#define PCL_FALLTHROUGH ;
375+
#define PCL_FALLTHROUGH
380376
#endif
381377

382-
#if __has_cpp_attribute(nodiscard)
378+
#if (__cplusplus >= 201703L) || (defined(_MSC_VER) && (_MSC_VER >= 1911) && (_MSVC_LANG >= 201703L))
383379
#define PCL_NODISCARD [[nodiscard]]
380+
#elif defined(__clang__) && (PCL_LINEAR_VERSION(__clang_major__, __clang_minor__, 0) >= PCL_LINEAR_VERSION(3, 9, 0))
381+
#define PCL_NODISCARD [[clang::warn_unused_result]]
382+
#elif defined(__GNUC__)
383+
#define PCL_NODISCARD [[gnu::warn_unused_result]]
384384
#else
385385
#define PCL_NODISCARD
386386
#endif

common/src/PCLPointCloud2.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,8 @@ pcl::PCLPointCloud2::concatenate (pcl::PCLPointCloud2 &cloud1, const pcl::PCLPoi
6363
{
6464
case 1:
6565
cloud1 = cloud2;
66-
PCL_FALLTHROUGH;
66+
PCL_FALLTHROUGH
6767
case 0:
68-
PCL_FALLTHROUGH;
6968
case 2:
7069
cloud1.header.stamp = std::max (cloud1.header.stamp, cloud2.header.stamp);
7170
return (true);

common/src/pcl_base.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,14 @@ pcl::PCLBase<pcl::PCLPointCloud2>::setInputCloud (const PCLPointCloud2ConstPtr &
7676
{
7777
switch (datatype)
7878
{
79-
case pcl::PCLPointField::INT8: PCL_FALLTHROUGH;
79+
case pcl::PCLPointField::INT8:
8080
case pcl::PCLPointField::UINT8: return 1;
8181

82-
case pcl::PCLPointField::INT16: PCL_FALLTHROUGH;
82+
case pcl::PCLPointField::INT16:
8383
case pcl::PCLPointField::UINT16: return 2;
8484

85-
case pcl::PCLPointField::INT32: PCL_FALLTHROUGH;
86-
case pcl::PCLPointField::UINT32: PCL_FALLTHROUGH;
85+
case pcl::PCLPointField::INT32:
86+
case pcl::PCLPointField::UINT32:
8787
case pcl::PCLPointField::FLOAT32: return 4;
8888

8989
case pcl::PCLPointField::FLOAT64: return 8;

0 commit comments

Comments
 (0)