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

Avitab does not build on Mac after recent Xcode update #181

Closed
mjh65 opened this issue Nov 21, 2023 · 5 comments · Fixed by #201
Closed

Avitab does not build on Mac after recent Xcode update #181

mjh65 opened this issue Nov 21, 2023 · 5 comments · Fixed by #201
Assignees

Comments

@mjh65
Copy link
Collaborator

mjh65 commented Nov 21, 2023

The Avitab build fails on Mac OSX due to a deprecation warning being treated as an error:

build-third/include/nlohmann/json.hpp:6217:19: error: 'char_traits<unsigned char>' is deprecated: char_traits<T> for T not equal to char, wchar_t, char8_t, char16_t or char32_t is non-standard and is provided for a temporary period. It will be removed in LLVM 18, so please migrate off of it. [-Werror,-Wdeprecated-declarations]
    typename std::char_traits<char_type>::int_type get_character()
                  ^

I don't regularly build Avitab on the Mac. Since the previous build I have updated Xcode (possibly more than once).

The current compiler version is Apple clang version 15.0.0 (clang-1500.0.40.1). This is based on LLVM, who have issued this deprecation warning and explanation: https://discourse.llvm.org/t/deprecating-std-string-t-for-non-character-t/66779

I checked the nlohmann/json project on github to see if a more recent release would fix this. The latest release still has this issue, however the issue has been reported (nlohmann/json#4163) and is being worked on (nlohmann/json#4179).

I think once the issue is fixed in the nlohmann/json library then Avitab should be updated to reference a fixed version.

@fpw
Copy link
Owner

fpw commented Nov 21, 2023

Fixed by #182

@fpw fpw closed this as completed Nov 21, 2023
@mjh65
Copy link
Collaborator Author

mjh65 commented Nov 21, 2023

I was wondering if this issue should remain open until a proper fix can be put in place by updating to the (next?) version of nlohmann/json? The masking of deprecation warnings should be removed from the CMakeLists file at the same time - it's only really intended as a temporary fix.

@fpw
Copy link
Owner

fpw commented Nov 21, 2023

Ah, good point.

@fpw fpw reopened this Nov 21, 2023
@mjh65
Copy link
Collaborator Author

mjh65 commented Nov 22, 2023

Following on from the temporary fix I submitted for the initial build issue, I have used cmake to generate an Xcode project, and this has highlighted some additional source code issues due to the default setting of the -Wconversion flag in the Xcode project (the flag is not set by default in the normal Makefile generator).

Many of the build errors are due to the use of an unsigned and/or long int variable as an argument to an int parameter. A lot of these are in the Avitab source and could be fixed with an explicit cast (or an overloaded function with an unsigned/long parameter). However, some of the issues are in third-party sources and cannot be easily fixed.

A simple solution is to add the -Wno-conversion compiler flag. This could be done globally in the top-level CMakeLists.txt file. Alternatively the flag could be added only where required (if 3rd party source/header is involved) and the rest of the Avitab sources can be tidied up to remove the warning.

I am happy to create a further PR to address this issue. Which approach is preferred?

@fpw
Copy link
Owner

fpw commented Nov 22, 2023

Thanks for the investigation! I think that Wconversion is a lot too strict for us, these kind of conversions are not undefined behaviour, they're just implicit. I understand that you might want them in projects that have to take care of functional safety, but we're not building real aviation gear here. I'd favor -Wno-conversion.

fpw added a commit that referenced this issue Nov 22, 2023
Fix build issues in Xcode on Mac OS X (issue #181)
@mjh65 mjh65 self-assigned this Mar 15, 2024
@mjh65 mjh65 linked a pull request Mar 15, 2024 that will close this issue
@fpw fpw closed this as completed in #201 Apr 22, 2024
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