"Initialization segment must not change during translation unit" error when unity build is enabled
What version of protobuf and what language are you using? Version: v3.20.1 (Linking to protobuf-lite but was able to reproduce with protobuf too) Language: C++
What operating system (Linux, Windows, ...) and version?
Windows 10 Enterprise 19044.1889
What runtime / compiler are you using (e.g., python version or gcc version)
MSVC 19.29
What did you do? Steps to reproduce the behavior:
- Unzip the attached file
- Run the command
cmake . -B out -G "Visual Studio 16 2019" -A x64 -DCMAKE_UNITY_BUILD=ON -DCMAKE_UNITY_BUILD_BATCH_SIZE=2 - Navigate to the generated "out" folder.
- Open up the project in visual studio 16 2019.
- Compile the project.
What did you expect to see
I expected the project to compile successfully.
What did you see instead?
I see C2356 error code that says "Initialization segment must not change during translation unit".
Make sure you include information that can help us debug (full error message, exception listing, stack trace, logs).
Anything else we should know about your project / environment
The same issue is with MSVC 2015. Looks like generated protobuf sources should be excluded from the Unity build.
Any updates on this?
We triage inactive PRs and issues in order to make it easier to find active work. If this issue should remain active or becomes active again, please add a comment.
This issue is labeled inactive because the last activity was over 90 days ago.
I believe this is still an issue, so I am adding a comment to reactivate it.
We triage inactive PRs and issues in order to make it easier to find active work. If this issue should remain active or becomes active again, please add a comment.
This issue is labeled inactive because the last activity was over 90 days ago.
We triage inactive PRs and issues in order to make it easier to find active work. If this issue should remain active or becomes active again, please reopen it.
This issue was closed and archived because there has been no new activity in the 14 days since the inactive label was added.