[MacPorts] #71632: boost176 @1.76.0_12 does not build on PPC Mac OS X 10.4.11, Tiger, because "command execution failed"?
MacPorts
noreply at macports.org
Mon Dec 30 17:56:11 UTC 2024
#71632: boost176 @1.76.0_12 does not build on PPC Mac OS X 10.4.11, Tiger, because
"command execution failed"?
------------------------+-----------------------
Reporter: ballapete | Owner: (none)
Type: defect | Status: new
Priority: Normal | Milestone:
Component: ports | Version: 2.10.5
Resolution: | Keywords: tiger ppc
Port: boost176 |
------------------------+-----------------------
Comment (by kencu):
ChatGPT's take:
{{{
The error in your build log indicates a conflict with the isdigit
function. The issue arises because isdigit is already defined in the
standard C library (<ctype.h> or <cwctype>), causing a naming conflict
with your custom isdigit implementation in
libs/locale/src/shared/mo_lambda.cpp.
Here's a breakdown of the issues and potential solutions:
Problem Explanation
Conflict with Standard Library Functionality:
isdigit is a standard library function that determines if a character is a
digit. Your code redefines isdigit, causing ambiguity during compilation.
Scope and Declaration Issues:
The compiler interprets calls to isdigit ambiguously since it cannot
distinguish between the custom implementation and the standard library
function.
Compilation Errors:
bool isdigit(char c) conflicts with the standard isdigit(int) function.
Usage of isdigit(*ptr) attempts to pass a char to a function expecting a
different type, exacerbating the issue.
Solutions
1. Rename Your Custom isdigit Function
Rename the conflicting function to avoid the name clash:
bool is_custom_digit(char c) {
return '0' <= c && c <= '9';
}
Update all references in mo_lambda.cpp to use is_custom_digit instead of
isdigit.
2. Explicit Namespace Usage
Wrap your custom isdigit function in a unique namespace to prevent
conflicts:
namespace custom {
bool isdigit(char c) {
return '0' <= c && c <= '9';
}
}
Call it explicitly using custom::isdigit(*ptr).
3. Include <ctype.h> or <cwctype> Before Your Code
To ensure proper resolution of the standard library function, explicitly
include the required headers:
#include <ctype.h>
Then, ensure your function does not interfere by renaming it or qualifying
its usage.
4. Use the Standard Library Function
If your custom isdigit function performs the same operation as the
standard library function, consider using the standard isdigit(int c)
directly. Note that it expects an int and may require casting:
if (isdigit(static_cast<unsigned char>(*ptr))) {
int_value = strtol(text + pos, &tmp_ptr, 0);
pos = tmp_ptr - text;
next_token = NUM;
}
5. Guard Against Macro Conflicts
If isdigit is being replaced by a macro in some headers, undefine it after
inclusion:
#include <ctype.h>
#undef isdigit
Action Plan
Search for all usages of isdigit in mo_lambda.cpp.
Apply one of the above solutions to resolve the naming conflict.
Rebuild the project to ensure the issue is resolved.
Would you like help implementing a specific solution or further
clarification on any of the steps?
}}}
--
Ticket URL: <https://trac.macports.org/ticket/71632#comment:4>
MacPorts <https://www.macports.org/>
Ports system for macOS
More information about the macports-tickets
mailing list