Using C99 functions in C++ applications when ambiguous definitions exist

The C++ standard namespace does not include any C99 functions. Therefore, when ambiguous definitions exist, C++ applications must access these functions through the global namespace. The syntax of the global namespace is ::function().

XL C++ applications that need C99 interfaces must use the required feature macros or, when ambiguous definitions exist, global namespace syntax (when ambiguous definitions exist).

Figure 1 is an example of code that requires the global namespace syntax. In this example, std:: is not allowed for C99 interfaces.

Figure 1. Example of code that requires the global namespace syntax
#include <cstdio>
namespace FRED {
  int snprintf(char *b, size_t x, const char *f, ...) { return(x); }
};
using namespace FRED;
main() {
  char buf[512];
  int rc;
/*rc = snprintf(buf,32,"hello\n");       AMBIGUOUS   */
  rc = ::snprintf(buf,32,"hello\n");
  rc = FRED::snprintf(buf,32,"hello\n");
/*rc = std::snprintf(buf,32,"hello\n");  NOT ALLOWED */
}