Skip to content

Commit 68e6e60

Browse files
committed
Fix missing link symbols with GCC 7.5.0 (Bionic)
1 parent 1b79e2a commit 68e6e60

File tree

1 file changed

+20
-10
lines changed

1 file changed

+20
-10
lines changed

libraries/YarpCloudUtils/YarpCloudUtils-pcl.cpp

+20-10
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,9 @@ namespace
189189

190190
template <typename T, std::enable_if_t<is_unsupported_type<T>, bool> = true>
191191
void meshFromCloudPCL(const typename pcl::PointCloud<T>::Ptr &, pcl::PolygonMesh::ConstPtr &, const yarp::sig::VectorOf<yarp::os::Property> &)
192-
{}
192+
{
193+
throw std::invalid_argument("unsupported point type"); // don't remove this
194+
}
193195

194196
template <typename T, std::enable_if_t<!is_unsupported_type<T>, bool> = true>
195197
void meshFromCloudPCL(const typename pcl::PointCloud<T>::Ptr & cloud, pcl::PolygonMesh::ConstPtr & mesh, const yarp::sig::VectorOf<yarp::os::Property> & options)
@@ -209,7 +211,9 @@ namespace
209211

210212
template <typename T1, typename T2, std::enable_if_t<is_unsupported_type<T1> || is_unsupported_type<T2>, bool> = true>
211213
void processCloudPCL(const typename pcl::PointCloud<T1>::Ptr &, typename pcl::PointCloud<T2>::ConstPtr &, const yarp::sig::VectorOf<yarp::os::Property> &)
212-
{}
214+
{
215+
throw std::invalid_argument("unsupported point type"); // don't remove this
216+
}
213217

214218
template <typename T1, typename T2, std::enable_if_t<!is_unsupported_type<T1> && !is_unsupported_type<T2>, bool> = true>
215219
void processCloudPCL(const typename pcl::PointCloud<T1>::Ptr & in, typename pcl::PointCloud<T2>::ConstPtr & out, const yarp::sig::VectorOf<yarp::os::Property> & options)
@@ -281,17 +285,19 @@ bool meshFromCloud(const yarp::sig::PointCloud<T1> & cloud,
281285
using pcl_input_type = typename pcl_type_from_yarp<T1>::type;
282286
using pcl_output_type = typename pcl_type_from_yarp<T2>::type;
283287

284-
// Force the compiler/linker to instantiate this signature of meshFromCloud for unsupported
285-
// point types. The following if clauses would make GCC strip several symbols from the .so.
286-
typename pcl::PointCloud<pcl_input_type>::Ptr pclCloud(new pcl::PointCloud<pcl_input_type>());
288+
// This variable and its following checks aim to override compiler optimizations, thus forcing
289+
// the compiler/linker to instantiate this signature of meshFromCloud for unsupported point types.
290+
// Otherwise, plain is_unsupported_type checks would make GCC strip several symbols from the .so.
291+
292+
volatile auto dummy = true;
287293

288-
if (is_unsupported_type<pcl_input_type>)
294+
if (is_unsupported_type<pcl_input_type> && dummy)
289295
{
290296
yError() << "unsupported input point type" << pcl_descriptor<pcl_input_type>::name;
291297
return false;
292298
}
293299

294-
if (is_unsupported_type<pcl_output_type>)
300+
if (is_unsupported_type<pcl_output_type> && dummy)
295301
{
296302
yError() << "unsupported output point type" << pcl_descriptor<pcl_output_type>::name;
297303
return false;
@@ -303,6 +309,8 @@ bool meshFromCloud(const yarp::sig::PointCloud<T1> & cloud,
303309
return false;
304310
}
305311

312+
typename pcl::PointCloud<pcl_input_type>::Ptr pclCloud(new pcl::PointCloud<pcl_input_type>());
313+
306314
// Convert YARP cloud to PCL cloud.
307315
yarp::pcl::toPCL(cloud, *pclCloud);
308316

@@ -354,15 +362,15 @@ bool processCloud(const yarp::sig::PointCloud<T1> & in,
354362
using pcl_output_type = typename pcl_type_from_yarp<T2>::type;
355363

356364
// See analogous comment in meshFromCloud.
357-
typename pcl::PointCloud<pcl_input_type>::Ptr pclCloudIn(new pcl::PointCloud<pcl_input_type>());
365+
volatile auto dummy = true;
358366

359-
if (is_unsupported_type<pcl_input_type>)
367+
if (is_unsupported_type<pcl_input_type> && dummy)
360368
{
361369
yError() << "unsupported input point type" << pcl_descriptor<pcl_input_type>::name;
362370
return false;
363371
}
364372

365-
if (is_unsupported_type<pcl_output_type>)
373+
if (is_unsupported_type<pcl_output_type> && dummy)
366374
{
367375
yError() << "unsupported output point type" << pcl_descriptor<pcl_output_type>::name;
368376
return false;
@@ -374,6 +382,8 @@ bool processCloud(const yarp::sig::PointCloud<T1> & in,
374382
return false;
375383
}
376384

385+
typename pcl::PointCloud<pcl_input_type>::Ptr pclCloudIn(new pcl::PointCloud<pcl_input_type>());
386+
377387
// Convert YARP cloud to PCL cloud.
378388
yarp::pcl::toPCL(in, *pclCloudIn);
379389

0 commit comments

Comments
 (0)