Skip to content

Commit

Permalink
Test hidden visibility default on gcc
Browse files Browse the repository at this point in the history
  • Loading branch information
mvieth committed Mar 1, 2024
1 parent 14a8bde commit 572c341
Show file tree
Hide file tree
Showing 18 changed files with 108 additions and 137 deletions.
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,9 @@ if(CMAKE_COMPILER_IS_GNUCXX)
endif()
string(APPEND CMAKE_CXX_FLAGS " -Wall -Wextra -fno-strict-aliasing ${SSE_FLAGS} ${AVX_FLAGS}")
endif()
if(PCL_SYMBOL_VISIBILITY_HIDDEN)
string(APPEND CMAKE_CXX_FLAGS " -fvisibility=hidden -fvisibility-inlines-hidden")
endif()

if(PCL_WARNINGS_ARE_ERRORS)
string(APPEND CMAKE_CXX_FLAGS " -Werror -fno-strict-aliasing")
Expand Down Expand Up @@ -229,6 +232,9 @@ if(CMAKE_COMPILER_IS_CLANG)
string(APPEND CMAKE_CXX_FLAGS " -stdlib=libstdc++")
endif()
endif()
if(PCL_SYMBOL_VISIBILITY_HIDDEN)
string(APPEND CMAKE_CXX_FLAGS " -fvisibility=hidden -fvisibility-inlines-hidden")
endif()
set(CLANG_LIBRARIES "stdc++")
endif()

Expand Down
4 changes: 4 additions & 0 deletions cmake/pcl_options.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,7 @@ option(PCL_DISABLE_GPU_TESTS "Disable running GPU tests. If disabled, tests will
# Set whether visualizations tests should be run
# (Used to prevent visualizations tests from executing in CI where visualization is unavailable)
option(PCL_DISABLE_VISUALIZATION_TESTS "Disable running visualizations tests. If disabled, tests will still be built." OFF)

# This leads to smaller libraries, possibly faster code, and fixes some bugs. See https://gcc.gnu.org/wiki/Visibility
option(PCL_SYMBOL_VISIBILITY_HIDDEN "Hide all binary symbols by default, export only those explicitly marked (gcc and clang only). Experimental!" ON)
mark_as_advanced(PCL_SYMBOL_VISIBILITY_HIDDEN)
4 changes: 2 additions & 2 deletions common/include/pcl/common/intersections.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ namespace pcl
* \param[in] angular_tolerance tolerance in radians
* \return true if succeeded/planes aren't parallel
*/
PCL_EXPORTS template <typename Scalar> bool
template <typename Scalar> PCL_EXPORTS bool
planeWithPlaneIntersection (const Eigen::Matrix<Scalar, 4, 1> &plane_a,
const Eigen::Matrix<Scalar, 4, 1> &plane_b,
Eigen::Matrix<Scalar, Eigen::Dynamic, 1> &line,
Expand Down Expand Up @@ -121,7 +121,7 @@ namespace pcl
* \param[out] intersection_point the three coordinates x, y, z of the intersection point
* \return true if succeeded/planes aren't parallel
*/
PCL_EXPORTS template <typename Scalar> bool
template <typename Scalar> PCL_EXPORTS bool
threePlanesIntersection (const Eigen::Matrix<Scalar, 4, 1> &plane_a,
const Eigen::Matrix<Scalar, 4, 1> &plane_b,
const Eigen::Matrix<Scalar, 4, 1> &plane_c,
Expand Down
23 changes: 12 additions & 11 deletions common/include/pcl/exceptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#include <stdexcept>
#include <sstream>
#include <boost/current_function.hpp>
#include <pcl/pcl_exports.h> // for PCL_EXPORTS

/** PCL_THROW_EXCEPTION a helper macro to be used for throwing exceptions.
* This is an example on how to use:
Expand All @@ -60,7 +61,7 @@ namespace pcl
* \brief A base class for all pcl exceptions which inherits from std::runtime_error
* \author Eitan Marder-Eppstein, Suat Gedikli, Nizar Sallem
*/
class PCLException : public std::runtime_error
class PCL_EXPORTS PCLException : public std::runtime_error
{
public:

Expand Down Expand Up @@ -132,7 +133,7 @@ namespace pcl
/** \class InvalidConversionException
* \brief An exception that is thrown when a PCLPointCloud2 message cannot be converted into a PCL type
*/
class InvalidConversionException : public PCLException
class PCL_EXPORTS InvalidConversionException : public PCLException
{
public:

Expand All @@ -146,7 +147,7 @@ namespace pcl
/** \class IsNotDenseException
* \brief An exception that is thrown when a PointCloud is not dense but is attempted to be used as dense
*/
class IsNotDenseException : public PCLException
class PCL_EXPORTS IsNotDenseException : public PCLException
{
public:

Expand All @@ -161,7 +162,7 @@ namespace pcl
* \brief An exception that is thrown when a sample consensus model doesn't
* have the correct number of samples defined in model_types.h
*/
class InvalidSACModelTypeException : public PCLException
class PCL_EXPORTS InvalidSACModelTypeException : public PCLException
{
public:

Expand All @@ -175,7 +176,7 @@ namespace pcl
/** \class IOException
* \brief An exception that is thrown during an IO error (typical read/write errors)
*/
class IOException : public PCLException
class PCL_EXPORTS IOException : public PCLException
{
public:

Expand All @@ -190,7 +191,7 @@ namespace pcl
* \brief An exception thrown when init can not be performed should be used in all the
* PCLBase class inheritants.
*/
class InitFailedException : public PCLException
class PCL_EXPORTS InitFailedException : public PCLException
{
public:
InitFailedException (const std::string& error_description = "",
Expand All @@ -204,7 +205,7 @@ namespace pcl
* \brief An exception that is thrown when an organized point cloud is needed
* but not provided.
*/
class UnorganizedPointCloudException : public PCLException
class PCL_EXPORTS UnorganizedPointCloudException : public PCLException
{
public:

Expand All @@ -218,7 +219,7 @@ namespace pcl
/** \class KernelWidthTooSmallException
* \brief An exception that is thrown when the kernel size is too small
*/
class KernelWidthTooSmallException : public PCLException
class PCL_EXPORTS KernelWidthTooSmallException : public PCLException
{
public:

Expand All @@ -229,7 +230,7 @@ namespace pcl
: pcl::PCLException (error_description, file_name, function_name, line_number) { }
} ;

class UnhandledPointTypeException : public PCLException
class PCL_EXPORTS UnhandledPointTypeException : public PCLException
{
public:
UnhandledPointTypeException (const std::string& error_description,
Expand All @@ -239,7 +240,7 @@ namespace pcl
: pcl::PCLException (error_description, file_name, function_name, line_number) { }
};

class ComputeFailedException : public PCLException
class PCL_EXPORTS ComputeFailedException : public PCLException
{
public:
ComputeFailedException (const std::string& error_description,
Expand All @@ -252,7 +253,7 @@ namespace pcl
/** \class BadArgumentException
* \brief An exception that is thrown when the arguments number or type is wrong/unhandled.
*/
class BadArgumentException : public PCLException
class PCL_EXPORTS BadArgumentException : public PCLException
{
public:
BadArgumentException (const std::string& error_description,
Expand Down
2 changes: 1 addition & 1 deletion common/include/pcl/pcl_exports.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,5 @@
#define PCL_EXPORTS
#endif
#else
#define PCL_EXPORTS
#define PCL_EXPORTS __attribute__ ((visibility ("default")))
#endif
2 changes: 1 addition & 1 deletion common/include/pcl/pcl_macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ pcl_round (float number)
#define PCL_EXPORTS
#endif
#else
#define PCL_EXPORTS
#define PCL_EXPORTS __attribute__ ((visibility ("default")))
#endif

#if defined WIN32 || defined _WIN32
Expand Down
54 changes: 27 additions & 27 deletions common/include/pcl/range_image/range_image.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ namespace pcl
* \author Bastian Steder
* \ingroup range_image
*/
class RangeImage : public pcl::PointCloud<PointWithRange>
class PCL_EXPORTS RangeImage : public pcl::PointCloud<PointWithRange>
{
public:
// =====TYPEDEFS=====
Expand All @@ -69,9 +69,9 @@ namespace pcl

// =====CONSTRUCTOR & DESTRUCTOR=====
/** Constructor */
PCL_EXPORTS RangeImage ();
RangeImage ();
/** Destructor */
PCL_EXPORTS virtual ~RangeImage () = default;
virtual ~RangeImage () = default;

// =====STATIC VARIABLES=====
/** The maximum number of openmp threads that can be used in this class */
Expand Down Expand Up @@ -99,7 +99,7 @@ namespace pcl
* \param coordinate_frame the input coordinate frame
* \param transformation the resulting transformation that warps \a coordinate_frame into CAMERA_FRAME
*/
PCL_EXPORTS static void
static void
getCoordinateFrameTransformation (RangeImage::CoordinateFrame coordinate_frame,
Eigen::Affine3f& transformation);

Expand All @@ -115,7 +115,7 @@ namespace pcl
* \param point_cloud_data a PCLPointCloud2 message containing the input cloud
* \param far_ranges the resulting cloud containing those points with far ranges
*/
PCL_EXPORTS static void
static void
extractFarRanges (const pcl::PCLPointCloud2& point_cloud_data, PointCloud<PointWithViewpoint>& far_ranges);

// =====METHODS=====
Expand All @@ -124,7 +124,7 @@ namespace pcl
makeShared () { return Ptr (new RangeImage (*this)); }

/** \brief Reset all values to an empty range image */
PCL_EXPORTS void
void
reset ();

/** \brief Create the depth image from a point cloud
Expand Down Expand Up @@ -321,14 +321,14 @@ namespace pcl
* \param bottom if positive, this value overrides the position of the bottom edge (defaults to -1)
* \param left if positive, this value overrides the position of the left edge (defaults to -1)
*/
PCL_EXPORTS void
void
cropImage (int border_size=0, int top=-1, int right=-1, int bottom=-1, int left=-1);

/** \brief Get all the range values in one float array of size width*height
* \return a pointer to a new float array containing the range values
* \note This method allocates a new float array; the caller is responsible for freeing this memory.
*/
PCL_EXPORTS float*
float*
getRangesArray () const;

/** Getter for the transformation from the world system into the range image system
Expand Down Expand Up @@ -445,7 +445,7 @@ namespace pcl
calculate3DPoint (float image_x, float image_y, Eigen::Vector3f& point) const;

/** Recalculate all 3D point positions according to their pixel position and range */
PCL_EXPORTS void
void
recalculate3DPointPositions ();

/** Get imagePoint from 3D point in world coordinates */
Expand Down Expand Up @@ -568,7 +568,7 @@ namespace pcl
inline float
getImpactAngleBasedOnLocalNormal (int x, int y, int radius) const;
/** Uses the above function for every point in the image */
PCL_EXPORTS float*
float*
getImpactAngleImageBasedOnLocalNormals (int radius) const;

/** Calculate a score [0,1] that tells how acute the impact angle is (1.0f - getImpactAngle/90deg)
Expand All @@ -586,7 +586,7 @@ namespace pcl
getAcutenessValue (int x1, int y1, int x2, int y2) const;

/** Calculate getAcutenessValue for every point */
PCL_EXPORTS void
void
getAcutenessValueImages (int pixel_distance, float*& acuteness_value_image_x,
float*& acuteness_value_image_y) const;

Expand All @@ -597,11 +597,11 @@ namespace pcl
// const PointWithRange& neighbor2) const;

/** Calculates, how much the surface changes at a point. 1 meaning a 90deg angle and 0 a flat surface */
PCL_EXPORTS float
float
getSurfaceChange (int x, int y, int radius) const;

/** Uses the above function for every point in the image */
PCL_EXPORTS float*
float*
getSurfaceChangeImage (int radius) const;

/** Calculates, how much the surface changes at a point. Returns an angle [0.0f, PI] for x and y direction.
Expand All @@ -610,7 +610,7 @@ namespace pcl
getSurfaceAngleChange (int x, int y, int radius, float& angle_change_x, float& angle_change_y) const;

/** Uses the above function for every point in the image */
PCL_EXPORTS void
void
getSurfaceAngleChangeImages (int radius, float*& angle_change_image_x, float*& angle_change_image_y) const;

/** Calculates the curvature in a point using pca */
Expand All @@ -622,7 +622,7 @@ namespace pcl
getSensorPos () const;

/** Sets all -INFINITY values to INFINITY */
PCL_EXPORTS void
void
setUnseenToMaxRange ();

//! Getter for image_offset_x_
Expand Down Expand Up @@ -660,22 +660,22 @@ namespace pcl
getHalfImage (RangeImage& half_image) const;

//! Find the minimum and maximum range in the image
PCL_EXPORTS void
void
getMinMaxRanges (float& min_range, float& max_range) const;

//! This function sets the sensor pose to 0 and transforms all point positions to this local coordinate frame
PCL_EXPORTS void
void
change3dPointsToLocalCoordinateFrame ();

/** Calculate a range patch as the z values of the coordinate frame given by pose.
* The patch will have size pixel_size x pixel_size and each pixel
* covers world_size/pixel_size meters in the world
* You are responsible for deleting the structure afterwards! */
PCL_EXPORTS float*
float*
getInterpolatedSurfaceProjection (const Eigen::Affine3f& pose, int pixel_size, float world_size) const;

//! Same as above, but using the local coordinate frame defined by point and the viewing direction
PCL_EXPORTS float*
float*
getInterpolatedSurfaceProjection (const Eigen::Vector3f& point, int pixel_size, float world_size) const;

//! Get the local coordinate frame with 0,0,0 in point, upright and Z as the viewing direction
Expand All @@ -690,22 +690,22 @@ namespace pcl
getRotationToViewerCoordinateFrame (const Eigen::Vector3f& point, Eigen::Affine3f& transformation) const;

/** Get a local coordinate frame at the given point based on the normal. */
PCL_EXPORTS bool
bool
getNormalBasedUprightTransformation (const Eigen::Vector3f& point,
float max_dist, Eigen::Affine3f& transformation) const;

/** Get the integral image of the range values (used for fast blur operations).
* You are responsible for deleting it after usage! */
PCL_EXPORTS void
void
getIntegralImage (float*& integral_image, int*& valid_points_num_image) const;

/** Get a blurred version of the range image using box filters on the provided integral image*/
PCL_EXPORTS void // Template necessary so that this function also works in derived classes
void // Template necessary so that this function also works in derived classes
getBlurredImageUsingIntegralImage (int blur_radius, float* integral_image, int* valid_points_num_image,
RangeImage& range_image) const;

/** Get a blurred version of the range image using box filters */
PCL_EXPORTS virtual void // Template necessary so that this function also works in derived classes
virtual void // Template necessary so that this function also works in derived classes
getBlurredImage (int blur_radius, RangeImage& range_image) const;

/** Get the squared euclidean distance between the two image points.
Expand All @@ -717,7 +717,7 @@ namespace pcl
getAverageEuclideanDistance (int x, int y, int offset_x, int offset_y, int max_steps) const;

//! Project all points on the local plane approximation, thereby smoothing the surface of the scan
PCL_EXPORTS void
void
getRangeImageWithSmoothedSurface (int radius, RangeImage& smoothed_range_image) const;
//void getLocalNormals (int radius) const;

Expand All @@ -731,7 +731,7 @@ namespace pcl

/** Calculates the overlap of two range images given the relative transformation
* (from the given image to *this) */
PCL_EXPORTS float
float
getOverlap (const RangeImage& other_range_image, const Eigen::Affine3f& relative_transformation,
int search_radius, float max_distance, int pixel_step=1) const;

Expand All @@ -745,11 +745,11 @@ namespace pcl

/** Return a newly created Range image.
* Can be reimplemented in derived classes like RangeImagePlanar to return an image of the same type. */
PCL_EXPORTS virtual RangeImage*
virtual RangeImage*
getNew () const { return new RangeImage; }

/** Copy other to *this. Necessary for use in virtual functions that need to copy derived RangeImage classes (like RangeImagePlanar) */
PCL_EXPORTS virtual void
virtual void
copyTo (RangeImage& other) const;


Expand Down
12 changes: 0 additions & 12 deletions filters/src/convolution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,17 +189,5 @@ Convolution<pcl::RGB, pcl::RGB>::convolveOneColDense(int i, int j)
result.b = static_cast<std::uint8_t>(b);
return (result);
}

#ifndef PCL_NO_PRECOMPILE
#include <pcl/impl/instantiate.hpp>
#include <pcl/point_types.h>

PCL_INSTANTIATE_PRODUCT(
Convolution, ((pcl::RGB))((pcl::RGB)))

PCL_INSTANTIATE_PRODUCT(
Convolution, ((pcl::PointXYZRGB))((pcl::PointXYZRGB)))
#endif // PCL_NO_PRECOMPILE

} // namespace filters
} // namespace pcl
Loading

0 comments on commit 572c341

Please sign in to comment.