Repository navigation
Support building without RTTI - #13
Merged
Merged
Conversation
FakeIt used dynamic_cast and typeid internally, so it didn't compile with -fno-rtti and was unreliable with /GR-. Internal casts now use static_cast where the type is fixed at construction, and typed storage or virtual accessors where a virtual base is involved. Type names in messages come from __PRETTY_FUNCTION__ or __FUNCSIG__ instead of typeid. Mocks still get fake RTTI when RTTI is enabled, so typeid and dynamic_cast on mocks keep working. Tests skip the RTTI-specific cases when RTTI is off, and CI runs the suite with -fno-rtti on GCC and Clang. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 7f5234c6-fb97-4ca8-b48c-16a582a690d7
Comment on lines
+25
to
+35
| runs-on: ubuntu-22.04 | ||
| steps: | ||
| - uses: actions/checkout@v2 | ||
| - name: Build project | ||
| run: | | ||
| cd build | ||
| make -f clang_makefile all CXXFLAGS=-fno-rtti | ||
| - name: Run tests | ||
| run: | | ||
| cd build | ||
| ./fakeit_tests.exe |
Comment on lines
+50
to
+60
| runs-on: ubuntu-22.04 | ||
| steps: | ||
| - uses: actions/checkout@v2 | ||
| - name: Build project | ||
| run: | | ||
| cd build | ||
| make all CXXFLAGS=-fno-rtti | ||
| - name: Run tests | ||
| run: | | ||
| cd build | ||
| ./fakeit_tests.exe |
tristanschneider
approved these changes
Oct 23, 2026
tristanschneider
left a comment
Contributor
There was a problem hiding this comment.
Looks reasonable. I read through and indeed many of the places looked like they were correct downcasts where the dynamic cast was unnecessary extra safety. The RTTICompleteObjectLocator change apparently looks correct based on what AI is telling me about how that slot works for type information in msvc. I'm not thrilled about the precarious locations that need the rtti ifdefs but don't see a preferrable way around it, and anyway this is an area that doesn't need to change often.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
FakeIt used
dynamic_castandtypeidinternally, so it didn't compile with-fno-rttiand was unreliable with/GR-.static_castwhere the type is fixed at construction, and typed storage or virtual accessors where a virtual base is involved.__PRETTY_FUNCTION__/__FUNCSIG__instead oftypeid.typeidanddynamic_caston mocks keep working.include/.-fno-rttion GCC and Clang.Test results match master on GCC, Clang, MSVC and clang-cl, and are the same without RTTI apart from the skipped RTTI tests.
Verified with Mojang/Minecraftpe#99080.