Skip to content

Add MSVC support by using a DEFER macro and increasing the evaluation depth. #7

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

Merged
merged 2 commits into from
Apr 14, 2025

Conversation

Erlkoenig90
Copy link
Contributor

In addition to my previous PR #6, this branch adds support for the MS Visual C++ compiler, fixing bug #4 . To achieve this, evaluation of the variadic macros is delayed by a "DEFER" macro. This requires the evaluation depth to be increased, by adding further levels to the "EVAL" recursion. Oddly, a different amount of levels is required for MSVC and GCC. The approach for generating commas for MAP_LIST had to be changed into using three instead of two different variants of MAP_LIST to have all instantiations except the first one emit a comma. I am not sure that this is the most elegant solution, but it appears to work (GCC 7.2.0, MSVC 2017 15.6.4).

@gahr
Copy link

gahr commented Apr 8, 2025

Hi @Erlkoenig90 - would you be willing to rebase your branch on top of ce95c50, if you agree on your work to be put in the public domain too?

@swansontec
Copy link
Owner

Thanks, and sorry for the delay in responding. I reviewed the code, and it all looks good. If you rebase onto master, I can go ahead and merge it.

@Erlkoenig90
Copy link
Contributor Author

Thanks, and sorry for the delay in responding

I guess we're all busy sometimes for a while 😁

if you agree on your work to be put in the public domain

In my jurisdiction, intellectual works cannot be willingly released into public domain (by the author), I can only give an unlimited license to use the work. Therefore I would propose to use a public-domain-equivalent license such as CC0 to guarantee international legal and declaim any warranties.

@swansontec
Copy link
Owner

swansontec commented Apr 11, 2025

Good idea. I went ahead and applied CC0 to the repo.

These macros allow the user to pass a single value to all invocations of the user macro,
and the *_I variants additionally pass the index of the invocation as an integer literal.
This requires a list of predefined increment operations. Updated the documentation
accordingly, and added an overview and a link to the µSer library to README.md.
@Erlkoenig90
Copy link
Contributor Author

Great! It's rebased now ;-)

@Erlkoenig90
Copy link
Contributor Author

Nice! I guess we can then also close #4 and #5 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants