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

Missing identifier 'ctz'/'ctzll' when compiling with MSVC and /clr #2176

Closed
Brainy0207 opened this issue Mar 12, 2021 · 1 comment · Fixed by #2179
Closed

Missing identifier 'ctz'/'ctzll' when compiling with MSVC and /clr #2176

Brainy0207 opened this issue Mar 12, 2021 · 1 comment · Fixed by #2179

Comments

@Brainy0207
Copy link
Contributor

If I try to use fmt in a MSVC project with /clr enabled, I get the following errors:

1>D:\Temp\ConsoleApplication1\fmt-7.1.3\include\fmt\format-inl.h(2017,11): error C3861: 'ctz': identifier not found
1>D:\Temp\ConsoleApplication1\fmt-7.1.3\include\fmt\format-inl.h(2045,11): error C3861: 'ctzll': identifier not found

Here is a simple example to reproduce these errors:

#define FMT_HEADER_ONLY
#include <fmt/format.h>

int main()
{
}

It seems due to _MANAGED beeing defined in /clr builds, the replacement funtions for 'clz', 'clzll', 'ctz' and 'ctzll' are never defined and missing.

fmt/include/fmt/format.h

Lines 206 to 207 in af56753

#if FMT_MSC_VER && !defined(FMT_BUILTIN_CLZLL) && \
!defined(FMT_BUILTIN_CTZLL) && !defined(_MANAGED)

I think the better approach here would be to remove the _MANAGED check and instead force this section to native mode, to be able to use intrinsics without warnings:

// Switch to native
#pragma managed(push,off)
// Do native stuff here
#pragma managed(pop)
// Switch back to previous mode
@vitaut
Copy link
Contributor

vitaut commented Mar 12, 2021

I think the better approach here would be to remove the _MANAGED check and instead force this section to native mode, to be able to use intrinsics without warnings

Sure, a PR is welcome.

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 a pull request may close this issue.

2 participants