So I've got an app which compiles fine on windows, linux and a few variations of unix. I recently decided to port it to OSX when I ran into a snag.
I have a template which looks like this:
template<int (&F)(int)>
int safe_ctype(unsigned char c) { return F(c); }
the idea being to prevent sign extension from crashing certain implementations when given input values above 0x7f
. It is typically used like this:
safe_ctype<std::isspace>(ch);
This unfortunately doesn't work on OSX (using gcc 4.2). The error has to do with std::isspace
not having external linkage and therefore not applicable for templates. It turns out that on OSX, the ctype.h
header has all functions (through macros) marked static inline
.
Here's my question:
Is it permitted by any relevant standard for functions in the C++ (in this case the parts inherited from C's) standard library to not have external linkage?
EDIT:
I've heard back from apple. Apparently they have a macro to control this behavior. Defining _DONT_USE_CTYPE_INLINE_
prevents the ctype functions from being static inline.