Repository navigation
Conversation
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.
A C or C++ caller trying to register a named event callback gets a compiler error for this ordinary call.
Today the macro uses
cbfor both its second parameter and the event's struct field. The preprocessor replaces both occurrences. With the call above, the compiler sees an assignment toevent.on_readyand reports thathevent_thas no such member.This change names the macro parameter
callback. The field name stayscb, so the call storeson_readyinevent.cb.Regression test
The new test sets a named function on a stack-allocated event, then checks that
hevent_cb(&event)returns that function. It failed to compile against the old header with GCC. With the fix it compiled and passed on Linux as C99 and as C++11. The C++ check used the public header copied by CMake. The Windows x64 C regression also compiled with MinGW and passed under Wine.The C test can be run on Linux with these commands.
cmake -S . -B build -DBUILD_UNITTEST=ON -DBUILD_EXAMPLES=OFF cmake --build build --target hevent_set_cb_test build/bin/hevent_set_cb_test