Skip to content

[vcpkg] Fix warning on Apple#5333

Merged
ras0219-msft merged 1 commit intomicrosoft:masterfrom
MASD-Project:apple_warning
Feb 9, 2019
Merged

[vcpkg] Fix warning on Apple#5333
ras0219-msft merged 1 commit intomicrosoft:masterfrom
MASD-Project:apple_warning

Conversation

@mcraveiro
Copy link
Contributor

This patch addresses a warning when compiling on OSX (I used LLVM Clang 7.0). The warning is as follows:

[12/64] Building CXX object CMakeFiles/vcpkg.dir/src/vcpkg/base/system.cpp.o
../src/vcpkg/base/system.cpp:34:52: warning: result of comparison of constant -1 with expression of type 'bool' is always true [-Wtautological-constant-out-of-range-compare]
        Checks::check_exit(VCPKG_LINE_INFO, result != -1, "Could not determine current executable path.");
                                            ~~~~~~ ^  ~~
../src/vcpkg/base/system.cpp:36:52: warning: result of comparison of constant -1 with expression of type 'bool' is always true [-Wtautological-constant-out-of-range-compare]
        Checks::check_exit(VCPKG_LINE_INFO, result != -1, "Could not determine current executable path.");
                                            ~~~~~~ ^  ~~
2 warnings generated.

The warning is the result of using bool as the return type of _NSGetExecutablePath, when the documentation states it is an int [1]:

bool result = _NSGetExecutablePath(buf, &size);

The patch sets result to match the return type of the function. It was tested using LLVM Clang 7.0 and compiles cleanly.

[1] https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man3/dyld.3.html

Return type of _NSGetExecutablePath is int rather than bool [1],
causing a warning on Apple.

[1] https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man3/dyld.3.html
@mcraveiro mcraveiro changed the title Fix warning on Apple [vcpkg] Fix warning on Apple Feb 8, 2019
@ras0219-msft ras0219-msft merged commit d82f37b into microsoft:master Feb 9, 2019
@ras0219-msft
Copy link
Contributor

ras0219-msft commented Feb 9, 2019

Thanks for the fix and thanks @zhihaoy for the review 👍 !

strega-nil pushed a commit to strega-nil/vcpkg that referenced this pull request May 5, 2021
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.

3 participants