-
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
for generated pb.cc files, avoid __FILE__ in VERIFY_VERSION macro call #3643
for generated pb.cc files, avoid __FILE__ in VERIFY_VERSION macro call #3643
Conversation
Can one of the admins verify this patch? |
Thanks for your pull request. The automated tests will run as soon as one of the admins verifies this change is ok for us to run on our infrastructure. |
1 similar comment
Thanks for your pull request. The automated tests will run as soon as one of the admins verifies this change is ok for us to run on our infrastructure. |
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed, please reply here (e.g.
|
cla: I signed it! |
CLAs look good, thanks! |
Unfortunately we cannot use NDEBUG in header files due to the reasons stated in: #3322 Can you think of a solution that doesn't require the use of NDEBUG macro? |
So the latest revision uses a relative path to proto file without ".proto" extension as the name ("google/proto/descriptor") and for most users simply "MyProtoMessage". Personally, I would prefer DEBUG or NDEBUG to enable/disable FILE usage. The issues in #3322 that are a concern are only for changes that alter the behavior or message hash. Etiher way, this pull request is ready for review. |
Sorry for the late response. If you only need to hide the prefix of the build path, maybe you can build it in a place where the prefix doesn't matter? For example, /home/build/.... The alternative is for protobuf code base to support a GOOGLE_PROTOBUF_NO_FILE_MACRO macro that you can define to switch off the use of FILE in our code base. If you are still interested in getting it in, feel free to reopen. |
Currently, whether generated .pb.cc files are built in release or debug mode, the source filenames are included as strings in the resulting binary.
This is because protoc-cpp adds a call to the GOOGLE_PROTOBUF_VERIFY_VERSION macro in the InitDefaultsImpl function of every generated C++ protobuf message file. That macro contains the FILE macro. Therefore, if you have a source file named MySpecialMessage.pb.cc, runnings strings on the resulting .o or .a or executable will reveal all the source file names. If you are using CMAKE for your build, it will include the absolute path of all .pb.cc files (e.g. "/Users/bob/dev/blah/generated/MySpecialMessage.pb.cc").
This change follows the behavior of the assert macro, which will omit FILE when NDEBUG is defined.