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

C2220: the following warning is treated as an error #4114

Closed
bipul-mohanto opened this issue Aug 9, 2024 · 5 comments
Closed

C2220: the following warning is treated as an error #4114

bipul-mohanto opened this issue Aug 9, 2024 · 5 comments
Labels

Comments

@bipul-mohanto
Copy link

Hi! I am using Visual Studio 2022 (x64: windows), to build Falcor SDK, that as fmt library as external.

While I am building the SDK as Debug, it is returning the above error: C2220: the following warning is treated as an error. The error shows to format.h line 559: template using checked_ptr = stdext::checked_array_iterator<T*>

The release build is working fine. I tried to lower the vS warning level to W3, disable Treat Warnings As Errors, also tried with the latest clone replacing the existing library. but it is no use. Any suggestion?

@vitaut
Copy link
Contributor

vitaut commented Aug 9, 2024

checked_array_iterator was removed back in 2023 (see #3540) so you might need to update to a more recent version to {fmt}.

@vitaut vitaut closed this as completed Aug 9, 2024
@vitaut vitaut added the question label Aug 9, 2024
@bipul-mohanto
Copy link
Author

bipul-mohanto commented Aug 12, 2024

So, are you suggesting replacing my existing fmt with the latest one? I have tried with the Release 11.0.2, however, getting errors in both release and debug build as:
Is any specific version compatible with Falcor? Falcor has the default fmt version: 10.0.0 - 2023-05-09

7>C:\Users\local-admin\Desktop\Falcor\external\fmt\include\fmt\base.h(1402,23): error C2662:         with
7>C:\Users\local-admin\Desktop\Falcor\external\fmt\include\fmt\base.h(1402,23): error C2662:         [
7>C:\Users\local-admin\Desktop\Falcor\external\fmt\include\fmt\base.h(1402,23): error C2662:             Context=fmt::v11::format_context,
7>C:\Users\local-admin\Desktop\Falcor\external\fmt\include\fmt\base.h(1402,23): error C2662:             FormatContext=fmt::v11::format_context
7>C:\Users\local-admin\Desktop\Falcor\external\fmt\include\fmt\base.h(1402,23): error C2662:         ]
7>C:\Users\local-admin\Desktop\Falcor\external\fmt\include\fmt\base.h(1402,23): error C2662:         and
7>C:\Users\local-admin\Desktop\Falcor\external\fmt\include\fmt\base.h(1402,23): error C2662:         [
7>C:\Users\local-admin\Desktop\Falcor\external\fmt\include\fmt\base.h(1402,23): error C2662:             Formatter=fmt::v11::formatter<std::filesystem::path,char,void>
7>C:\Users\local-admin\Desktop\Falcor\external\fmt\include\fmt\base.h(1402,23): error C2662:         ]
7>C:\Users\local-admin\Desktop\Falcor\external\fmt\include\fmt\base.h(1402,23): error C2662: 'fmt::v11::appender fmt::v11::formatter<std::filesystem::path,char,void>::format<Context>(const std::filesystem::path &,FormatContext &)': cannot convert 'this' pointer from 'const Formatter' to 'fmt::v11::formatter<std::filesystem::path,char,void> &'
7>C:\Users\local-admin\Desktop\Falcor\external\fmt\include\fmt\base.h(1402,23): error C2662:         with
7>C:\Users\local-admin\Desktop\Falcor\external\fmt\include\fmt\base.h(1402,23): error C2662:         [
7>C:\Users\local-admin\Desktop\Falcor\external\fmt\include\fmt\base.h(1402,23): error C2662:             Context=fmt::v11::format_context,
7>C:\Users\local-admin\Desktop\Falcor\external\fmt\include\fmt\base.h(1402,23): error C2662:             FormatContext=fmt::v11::format_context
7>C:\Users\local-admin\Desktop\Falcor\external\fmt\include\fmt\base.h(1402,23): error C2662:         ]
7>C:\Users\local-admin\Desktop\Falcor\external\fmt\include\fmt\base.h(1402,23): error C2662:         and
7>C:\Users\local-admin\Desktop\Falcor\external\fmt\include\fmt\base.h(1402,23): error C2662:         [
7>C:\Users\local-admin\Desktop\Falcor\external\fmt\include\fmt\base.h(1402,23): error C2662:             Formatter=fmt::v11::formatter<std::filesystem::path,char,void>
7>C:\Users\local-admin\Desktop\Falcor\external\fmt\include\fmt\base.h(1402,23): error C2662:         ]
7>C:\Users\local-admin\Desktop\Falcor\external\fmt\include\fmt\base.h(1402,23): error C2662: 'fmt::v11::appender fmt::v11::formatter<std::filesystem::path,char,void>::format<Context>(const std::filesystem::path &,FormatContext &)': cannot convert 'this' pointer from 'const Formatter' to 'fmt::v11::formatter<std::filesystem::path,char,void> &'
7>C:\Users\local-admin\Desktop\Falcor\external\fmt\include\fmt\base.h(1402,23): error C2662:         with
7>C:\Users\local-admin\Desktop\Falcor\external\fmt\include\fmt\base.h(1402,23): error C2662:         [
7>C:\Users\local-admin\Desktop\Falcor\external\fmt\include\fmt\base.h(1402,23): error C2662:             Context=fmt::v11::format_context,
7>C:\Users\local-admin\Desktop\Falcor\external\fmt\include\fmt\base.h(1402,23): error C2662:             FormatContext=fmt::v11::format_context
7>C:\Users\local-admin\Desktop\Falcor\external\fmt\include\fmt\base.h(1402,23): error C2662:         ]
7>C:\Users\local-admin\Desktop\Falcor\external\fmt\include\fmt\base.h(1402,23): error C2662:         and
7>C:\Users\local-admin\Desktop\Falcor\external\fmt\include\fmt\base.h(1402,23): error C2662:         [
7>C:\Users\local-admin\Desktop\Falcor\external\fmt\include\fmt\base.h(1402,23): error C2662:             Formatter=fmt::v11::formatter<std::filesystem::path,char,void>
7>C:\Users\local-admin\Desktop\Falcor\external\fmt\include\fmt\base.h(1402,23): error C2662:         ]
7>C:\Users\local-admin\Desktop\Falcor\external\fmt\include\fmt\base.h(1402,23): error C2662: 'fmt::v11::appender fmt::v11::formatter<std::filesystem::path,char,void>::format<Context>(const std::filesystem::path &,FormatContext &)': cannot convert 'this' pointer from 'const Formatter' to 'fmt::v11::formatter<std::filesystem::path,char,void> &'
7>C:\Users\local-admin\Desktop\Falcor\external\fmt\include\fmt\base.h(1402,23): error C2662:         with
7>C:\Users\local-admin\Desktop\Falcor\external\fmt\include\fmt\base.h(1402,23): error C2662:         [
7>C:\Users\local-admin\Desktop\Falcor\external\fmt\include\fmt\base.h(1402,23): error C2662:             Context=fmt::v11::format_context,
7>C:\Users\local-admin\Desktop\Falcor\external\fmt\include\fmt\base.h(1402,23): error C2662:             FormatContext=fmt::v11::format_context
7>C:\Users\local-admin\Desktop\Falcor\external\fmt\include\fmt\base.h(1402,23): error C2662:         ]
7>C:\Users\local-admin\Desktop\Falcor\external\fmt\include\fmt\base.h(1402,23): error C2662:         and
7>C:\Users\local-admin\Desktop\Falcor\external\fmt\include\fmt\base.h(1402,23): error C2662:         [
7>C:\Users\local-admin\Desktop\Falcor\external\fmt\include\fmt\base.h(1402,23): error C2662:             Formatter=fmt::v11::formatter<std::filesystem::path,char,void>
7>C:\Users\local-admin\Desktop\Falcor\external\fmt\include\fmt\base.h(1402,23): error C2662:         ]
7>C:\Users\local-admin\Desktop\Falcor\external\fmt\include\fmt\base.h(1402,23): error C2662: 'fmt::v11::appender fmt::v11::formatter<std::filesystem::path,char,void>::format<Context>(const std::filesystem::path &,FormatContext &)': cannot convert 'this' pointer from 'const Formatter' to 'fmt::v11::formatter<std::filesystem::path,char,void> &'
7>C:\Users\local-admin\Desktop\Falcor\external\fmt\include\fmt\base.h(1402,23): error C2662:         with
7>C:\Users\local-admin\Desktop\Falcor\external\fmt\include\fmt\base.h(1402,23): error C2662:         [
7>C:\Users\local-admin\Desktop\Falcor\external\fmt\include\fmt\base.h(1402,23): error C2662:             Context=fmt::v11::format_context,
7>C:\Users\local-admin\Desktop\Falcor\external\fmt\include\fmt\base.h(1402,23): error C2662:             FormatContext=fmt::v11::format_context
7>C:\Users\local-admin\Desktop\Falcor\external\fmt\include\fmt\base.h(1402,23): error C2662:         ]
7>C:\Users\local-admin\Desktop\Falcor\external\fmt\include\fmt\base.h(1402,23): error C2662:         and
7>C:\Users\local-admin\Desktop\Falcor\external\fmt\include\fmt\base.h(1402,23): error C2662:         [
7>C:\Users\local-admin\Desktop\Falcor\external\fmt\include\fmt\base.h(1402,23): error C2662:             Formatter=fmt::v11::formatter<std::filesystem::path,char,void>
7>C:\Users\local-admin\Desktop\Falcor\external\fmt\include\fmt\base.h(1402,23): error C2662:         ]

@bipul-mohanto
Copy link
Author

bipul-mohanto commented Aug 12, 2024

I got a temporary solution; mention it here as a future reference.

Replace #if defined(_SECURE_SCL) && _SECURE_SCL with #if 0

// Make a checked iterator to avoid MSVC warnings.
template <typename T> using checked_ptr = stdext::checked_array_iterator<T*>;

@mwinterb
Copy link
Contributor

Falcor defines its own formatters for std types instead of using the definitions in fmt/std.h. Which is explicitly bad because of ODR violations. And for v11, they're bad because the format function isn't const. (Even before v11 they were required to be const if formatting ranges.) Some of their formatters for their own types do have format as const, but it isn't consistent.
https://github.com/NVIDIAGameWorks/Falcor/blob/master/Source/Falcor/Utils/StringFormatters.h#L35

@vitaut
Copy link
Contributor

vitaut commented Aug 12, 2024

I recommend reporting an issue to Falcor.

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

No branches or pull requests

3 participants