Skip to content
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

fix MSVC compilation error in DEBUG mode due to free macro #253

Merged
merged 1 commit into from
Aug 8, 2023
Merged

fix MSVC compilation error in DEBUG mode due to free macro #253

merged 1 commit into from
Aug 8, 2023

Conversation

polyvertex
Copy link
Contributor

Thanks for your library!

Using nanobind release 1.5.0, I faced the following compilation error with MSVC 2022 in DEBUG mode (_DEBUG defined) only due to macro free being defined as _free_dbg by Windows headers:

nb_func.cpp(94,20): error C2039: '_free_dbg': is not a member of 'nanobind::detail::func_data'

I am aware you wish to keep the project easily maintainable and this is a quick and least intrusive fix, however I am not yet familiar with nanobind so not sure it is the most ideal or correct approach.

Anyway here it is just in case :)

@wjakob
Copy link
Owner

wjakob commented Aug 7, 2023

This isn't a new issue, correct? I suppose that variable has been named free for a long time (since commit 765253b in Feb 2022). It was called free_capture before then. Can you rename it to that? (instead of freemem)

@polyvertex
Copy link
Contributor Author

This isn't a new issue, correct?

If you refer to the definition of macro free by Windows headers, no it is not new. No pun intended :)

It was called free_capture before then. Can you rename it to that?

Done!

@wjakob
Copy link
Owner

wjakob commented Aug 8, 2023

With "new", I was referring to the nanobind version. I assume that the failure also occurs on v1.4.0?

@polyvertex
Copy link
Contributor Author

polyvertex commented Aug 8, 2023

With "new", I was referring to the nanobind version. I assume that the failure also occurs on v1.4.0?

I did not test, but a quick glance at the source of 1.4.0 shows that it certainly does yes. For the same reason indeed. I.e. struct func_data_prelim has a member named free, which name collides with the macro defined by Windows headers when _DEBUG is defined

@wjakob wjakob merged commit 90b2677 into wjakob:master Aug 8, 2023
16 checks passed
@polyvertex polyvertex deleted the fix-free branch August 20, 2023 06:45
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.

2 participants