-
Notifications
You must be signed in to change notification settings - Fork 15.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
When exporting symbols, an include directive may be necessary #4198
Comments
If your code depends on symbols in mylib_export.h, it's a better practice to directly include that in your code instead of indirectly included from our generated code. |
Umm, but protobuf is also generating code using an export macro ( |
@TeBoring Thoughts on the above comment? |
I faced a similar problem (see ros-industrial/abb_libegm#63), and I am bit confused by this comment. The macro passed to I noticed that some projects deal with this problem by defining a custom generator (see https://bitbucket.org/osrf/gazebo/src/804410860234af97c5e309896dc007e8cde04ba8/gazebo/msgs/generator/GazeboGenerator.cc#lines-72 and https://bitbucket.org/ignitionrobotics/ign-msgs/src/18640ef6c31777e25953ae44b6ad10ed68c4993e/src/Generator.cc#lines-106), but it would be nice to be able to insert a user-specified included header without implementing a custom generator. If there is an interest in merging such an option, I would be happy to provide a PR. |
I think a PR with a test case would help a lot with this. I forget how I worked around it in the project that I found this with. But, getting the attention of a Googler back on this is probably a prerequisite given how I've seen other things happen on this project :( . Hopefully a PR would do that, but who knows. |
Interestingly, Chromium has a protoc wrapper that adds the necessary includes in the generated The motivation for this wrapper is indeed to correctly handle export macros, see: https://github.com/chromium/chromium/blob/80.0.3974.1/third_party/protobuf/proto_library.gni#L34 . |
The author of the latter doesn't have an (obvious) github username, but @gkraynov refactored the former last. Maybe they could get some attention on this to avoid having such a workaround in chromium's vendoring of protobuf in the future :) . |
In my specific case, the workaround that I found is to force the inclusion of the visibility header via the MSVC option |
@TeBoring |
It'd be nice to have an option to add
#include "mylib_export.h"
to generated.pb.h
files so that export symbols are defined before their use.The text was updated successfully, but these errors were encountered: