Skip to content

Commit 921d893

Browse files
authored
cppcheckexecutor.cpp: avoid -Wcast-qual warnings on macOS (#7749)
``` /Users/runner/work/cppcheck/cppcheck/cli/cppcheckexecutor.cpp:746:9: error: cast from 'const int *' to 'int *' drops const qualifier [-Werror,-Wcast-qual] 746 | if (WIFEXITED(res)) { | ^ [ 2%] Building CXX object lib/CMakeFiles/cppcheck-core.dir/symboldatabase.cpp.o /Applications/Xcode_16.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.0.sdk/usr/include/sys/wait.h:152:26: note: expanded from macro 'WIFEXITED' 152 | #define WIFEXITED(x) (_WSTATUS(x) == 0) | ^ /Applications/Xcode_16.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.0.sdk/usr/include/sys/wait.h:136:26: note: expanded from macro '_WSTATUS' 136 | #define _WSTATUS(x) (_W_INT(x) & 0177) | ^ /Applications/Xcode_16.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.0.sdk/usr/include/sys/wait.h:131:34: note: expanded from macro '_W_INT' 131 | #define _W_INT(w) (*(int *)&(w)) /* convert union wait to int */ | ^ ```
1 parent 817013f commit 921d893

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

cli/cppcheckexecutor.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -733,6 +733,9 @@ int CppCheckExecutor::executeCommand(std::string exe, std::vector<std::string> a
733733

734734
#ifdef _WIN32
735735
const int res = _pclose(p);
736+
#elif defined(__APPLE__) && defined(__MACH__)
737+
// the W* macros cast to int* on macOS
738+
int res = pclose(p);
736739
#else
737740
const int res = pclose(p);
738741
#endif

0 commit comments

Comments
 (0)