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 preprocessor warnings about undefined _MSVC_LANG #2676

Merged
merged 1 commit into from
Jul 3, 2023

Conversation

mandree
Copy link
Contributor

@mandree mandree commented Jul 3, 2023

Stricter compiler/settings, such as found during a build on FreeBSD with clang 14, issue warnings of the kind below.

/usr/local/include/exiv2/value.hpp:1272:31: warning: '_MSVC_LANG' is not defined, evaluates to 0 [-Wundef] fixed-width font helps here-- ^

Fix: Guard use of _MSVC_LANG by a check.

Personally, I found that MSVC has several feature-specific checks in predefined macros which might allow for one standards-based check that matches GCC/clang/MSVC rather than the split check for C++ standard and MSVC language version settings.

See https://en.cppreference.com/w/cpp/feature_test

I am not building Exiv2 on MSVC, so I cannot test/suggest anything here.

@ghost
Copy link

ghost commented Jul 3, 2023

👇 Click on the image for a new way to code review

Review these changes using an interactive CodeSee Map

Legend

CodeSee Map legend

kevinbackhouse
kevinbackhouse previously approved these changes Jul 3, 2023
@codecov
Copy link

codecov bot commented Jul 3, 2023

Codecov Report

Merging #2676 (2f2a926) into main (91af090) will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##             main    #2676   +/-   ##
=======================================
  Coverage   63.89%   63.89%           
=======================================
  Files         103      103           
  Lines       22313    22313           
  Branches    10799    10799           
=======================================
  Hits        14258    14258           
  Misses       5830     5830           
  Partials     2225     2225           
Impacted Files Coverage Δ
include/exiv2/slice.hpp 90.56% <ø> (ø)
include/exiv2/value.hpp 85.11% <ø> (ø)

@mandree
Copy link
Contributor Author

mandree commented Jul 3, 2023

Sorry about the broken formatting in the commit message... apparently one line from the warning paste got lost as well. I'll push again with a fixed commit log.

Stricter compiler/settings, such as found during a build
on FreeBSD with clang 14, issue warnings of the kind below.

/usr/local/include/exiv2/value.hpp:1272:31: warning: '_MSVC_LANG' is not defined, evaluates to 0 [-Wundef]

Fix: Guard use of _MSVC_LANG by a check.

Personally, I found that MSVC has several feature-specific
checks in predefined macros which might allow for one
standards-based check that matches GCC/clang/MSVC rather than the
split check for C++ standard and MSVC language version settings.

See https://en.cppreference.com/w/cpp/feature_test

I am not building Exiv2 on MSVC, so I cannot test/suggest
anything here.
@mandree mandree force-pushed the mandree-fix-_MSVC_LANG-undef-warning branch from aaa8761 to 2f2a926 Compare July 3, 2023 09:48
@mergify mergify bot dismissed kevinbackhouse’s stale review July 3, 2023 09:48

Pull request has been modified.

@kmilos
Copy link
Collaborator

kmilos commented Jul 3, 2023

Thanks.

Personally, I found that MSVC has several feature-specific checks in predefined macros which might allow for one standards-based check that matches GCC/clang/MSVC rather than the split check for C++ standard and MSVC language version settings.

So can we potentially remove this instead of patching, since we require C++17 now anyway? (I can't check MSVC either...)

@neheb
Copy link
Collaborator

neheb commented Jul 3, 2023

@kmilos no this is in the headers. We're keeping them C++11 compatible. The whole reason for using MSVC_LANG is because its __cplusplus macro is broken. Unfortunately for the _t/_v stuff, there's no standard feature test macro AFAIK.

@neheb neheb merged commit 901e8ba into Exiv2:main Jul 3, 2023
109 checks passed
@neheb
Copy link
Collaborator

neheb commented Jul 3, 2023

@Mergifyio backport 0.28.x

@mergify
Copy link
Contributor

mergify bot commented Jul 3, 2023

backport 0.28.x

✅ Backports have been created

@mandree mandree deleted the mandree-fix-_MSVC_LANG-undef-warning branch July 10, 2023 20:15
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.

None yet

4 participants