Repository navigation
Conversation
Share a generated C-compatible version header between both public APIs. Compile a C90 helper in the unit suite and compare its version values with the C++ interface; wire the header into CMake and Bazel.
This branch has not been deployed
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.
Including
snappy-c.hcurrently leavesSNAPPY_MAJOR,SNAPPY_MINOR,SNAPPY_PATCHLEVEL, andSNAPPY_VERSIONundefined. C applications cannot use those macros for feature checks, and includingsnappy-stubs-public.his not a workaround because it contains C++ declarations.Move the existing definitions into a generated
snappy-version.hshared by both public interfaces. The values and encoding remain unchanged. The new header uses C comments and no C++ declarations, so strict C90 consumers continue to compile. CMake installs it with the other public headers, and Bazel declares the corresponding generated-header dependencies.Closes #271.
The regression helper is compiled as C and returns all four macros to the existing C++ unit suite, which checks that both interfaces report the same version. CMake compiles that helper as standard C90. No compression behavior, function signatures, dependency versions, or workflow files change.
Validation on Ubuntu 22.04, GCC/G++ 11.4, CMake 3.22.1, and Ninja:
gcc -std=c90 -Wall -Wextra -Werror -pedantic-errors -I. -fsyntax-only snappy_c_version_test.cfails on all four undefined macros.ctest --test-dir .git/build-static --output-on-failure -V: all 26 unit tests pass. The existingDISABLED_MoreThan4GBtest remains disabled.find_package(Snappy CONFIG REQUIRED)consumers build and run against each installedSnappy::snappytarget.git diff --checkpasses.Bazel 9.3.2's normal
test //:snappy_unittestfails in unchangedsnappy-test.hbecause::gettimeofdayis undeclared. I reproduced that failure on pristine base946606459314e55d029c85f9a8c46f8809467f0f. With the local compiler workaround--cxxopt=-include --cxxopt=sys/time.h, the patched Bazel test target passes, including the C-header regression. The workaround is not committed. Bazel used two jobs, a 512 MiB JVM heap, and--repo_contents_cache=to keep its private cache layout compatible with Bazel 9.This is a draft because the normal Bazel test invocation still fails on the baseline. Other compilers and operating systems have not been tested locally.
Implemented and tested with Codex assistance.