2N/A/* C++ compatible function declaration macros. 2N/A Copyright (C) 2010 Free Software Foundation, Inc. 2N/A This program is free software: you can redistribute it and/or modify it 2N/A under the terms of the GNU General Public License as published 2N/A by the Free Software Foundation; either version 3 of the License, or 2N/A (at your option) any later version. 2N/A This program is distributed in the hope that it will be useful, 2N/A but WITHOUT ANY WARRANTY; without even the implied warranty of 2N/A MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 2N/A Lesser General Public License for more details. 2N/A You should have received a copy of the GNU General Public License 2N/A/* The three most frequent use cases of these macros are: 2N/A * For providing a substitute for a function that is missing on some 2N/A platforms, but is declared and works fine on the platforms on which 2N/A _GL_FUNCDECL_SYS (foo, ...); 2N/A _GL_CXXALIAS_SYS (foo, ...); 2N/A _GL_CXXALIASWARN (foo); 2N/A #elif defined GNULIB_POSIXCHECK 2N/A * For providing a replacement for a function that exists on all platforms, 2N/A # if !(defined __cplusplus && defined GNULIB_NAMESPACE) 2N/A # define foo rpl_foo 2N/A _GL_FUNCDECL_RPL (foo, ...); 2N/A _GL_CXXALIAS_RPL (foo, ...); 2N/A _GL_CXXALIAS_SYS (foo, ...); 2N/A _GL_CXXALIASWARN (foo); 2N/A #elif defined GNULIB_POSIXCHECK 2N/A * For providing a replacement for a function that exists on some platforms 2N/A is additionally either missing or undeclared on some other platforms: 2N/A # if !(defined __cplusplus && defined GNULIB_NAMESPACE) 2N/A # define foo rpl_foo 2N/A _GL_FUNCDECL_RPL (foo, ...); 2N/A _GL_CXXALIAS_RPL (foo, ...); 2N/A # if !@HAVE_FOO@ or if !@HAVE_DECL_FOO@ 2N/A _GL_FUNCDECL_SYS (foo, ...); 2N/A _GL_CXXALIAS_SYS (foo, ...); 2N/A _GL_CXXALIASWARN (foo); 2N/A #elif defined GNULIB_POSIXCHECK 2N/A/* _GL_EXTERN_C declaration; 2N/A performs the declaration with C linkage. */ 2N/A/* _GL_FUNCDECL_RPL (func, rettype, parameters_and_attributes); 2N/A declares a replacement function, named rpl_func, with the given prototype, 2N/A consisting of return type, parameters, and attributes. 2N/A _GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...) 2N/A _GL_ARG_NONNULL ((1))); 2N/A/* _GL_FUNCDECL_SYS (func, rettype, parameters_and_attributes); 2N/A declares the system function, named func, with the given prototype, 2N/A consisting of return type, parameters, and attributes. 2N/A _GL_FUNCDECL_SYS (open, int, (const char *filename, int flags, ...) 2N/A _GL_ARG_NONNULL ((1))); 2N/A/* _GL_CXXALIAS_RPL (func, rettype, parameters); 2N/A declares a C++ alias called GNULIB_NAMESPACE::func 2N/A that redirects to rpl_func, if GNULIB_NAMESPACE is defined. 2N/A _GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...)); 2N/A/* _GL_CXXALIAS_RPL_CAST_1 (func, rpl_func, rettype, parameters); 2N/A is like _GL_CXXALIAS_RPL_1 (func, rpl_func, rettype, parameters); 2N/A except that the C function rpl_func may have a slightly different 2N/A declaration. A cast is used to silence the "invalid conversion" error 2N/A that would otherwise occur. */ 2N/A/* _GL_CXXALIAS_SYS (func, rettype, parameters); 2N/A declares a C++ alias called GNULIB_NAMESPACE::func 2N/A that redirects to the system provided function func, if GNULIB_NAMESPACE 2N/A _GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...)); 2N/A /* If we were to write 2N/A rettype (*const func) parameters = ::func; 2N/A like above in _GL_CXXALIAS_RPL_1, the compiler could optimize calls 2N/A better (remove an indirection through a 'static' pointer variable), 2N/A but then the _GL_CXXALIASWARN macro below would cause a warning not only 2N/A for uses of ::func but also for uses of GNULIB_NAMESPACE::func. */ 2N/A/* _GL_CXXALIAS_SYS_CAST (func, rettype, parameters); 2N/A is like _GL_CXXALIAS_SYS (func, rettype, parameters); 2N/A except that the C function func may have a slightly different declaration. 2N/A A cast is used to silence the "invalid conversion" error that would 2N/A/* _GL_CXXALIAS_SYS_CAST2 (func, rettype, parameters, rettype2, parameters2); 2N/A is like _GL_CXXALIAS_SYS (func, rettype, parameters); 2N/A except that the C function is picked among a set of overloaded functions, 2N/A namely the one with rettype2 and parameters2. Two consecutive casts 2N/A are used to silence the "cannot find a match" and "invalid conversion" 2N/A errors that would otherwise occur. */ 2N/A /* The outer cast must be a reinterpret_cast. 2N/A The inner cast: When the function is defined as a set of overloaded 2N/A functions, it works as a static_cast<>, choosing the designated variant. 2N/A When the function is defined as a single variant, it works as a 2N/A reinterpret_cast<>. The parenthesized cast syntax works both ways. */ 2N/A/* _GL_CXXALIASWARN (func); 2N/A causes a warning to be emitted when ::func is used but not when 2N/A GNULIB_NAMESPACE::func is used. func must be defined without overloaded 2N/A we enable the warning only when not optimizing. */ 2N/A "The symbol ::" #
func " refers to the system function. " \
2N/A/* _GL_CXXALIASWARN1 (func, rettype, parameters_and_attributes); 2N/A causes a warning to be emitted when the given overloaded variant of ::func 2N/A is used but not when GNULIB_NAMESPACE::func is used. */ 2N/A we enable the warning only when not optimizing. */ 2N/A "The symbol ::" #
func " refers to the system function. " \
2N/A#
endif /* _GL_CXXDEFS_H */