forked from RobotLocomotion/drake
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[common] Provide drake_export and opt-in to Werror=attributes (RobotL…
…ocomotion#18677) As we start to be more careful with linker visibility, it's becoming ever more likely that -Wattributes warnings will leak to the console. Promote them to errors so that we see them and fix the problem.
- Loading branch information
1 parent
5f8fb14
commit 27f7e49
Showing
5 changed files
with
50 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#pragma once | ||
|
||
/** DRAKE_NO_EXPORT sets C++ code to use hidden linker visibility. | ||
Hidden visibility is appropriate for code that will be completely invisible to | ||
users, e.g., for header files that are bazel-private, not installed, and only | ||
used as implementation_deps. | ||
This macro is most useful when Drake code includes externals that themselves | ||
have hidden linker visibility and compilers complain about mismatched | ||
visibility attributes. | ||
For example, to un-export all classes and functions in a namespace: | ||
<pre> | ||
namespace internal DRAKE_NO_EXPORT { | ||
class Foo { | ||
// ... | ||
}; | ||
} // namespace internal | ||
</pre> | ||
To un-export just one class: | ||
<pre> | ||
namespace internal { | ||
class DRAKE_NO_EXPORT Foo { | ||
// ... | ||
}; | ||
} // namespace internal | ||
</pre> | ||
To un-export just one function: | ||
<pre> | ||
DRAKE_NO_EXPORT void CalcFoo(double arg) { ... } | ||
</pre> | ||
For the related CMake module, see: | ||
https://cmake.org/cmake/help/latest/module/GenerateExportHeader.html | ||
*/ | ||
#define DRAKE_NO_EXPORT __attribute__((visibility("hidden"))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters