View Full Version : close (stdlib) inside namespace

May 1st, 2007, 07:02 PM
i 'got a little problem

i got a namespace with a memeber function called close(), that has to call the standard C funcion close():

namespace NS {
int close() {
return close(fd);

the internal close must be the close from stdlib, but the compiler complains about bad number of arguments.

i know there are c++ versions of sandard C libs (cstdlib, cstdio), but those don't cover other libs like fcntl

thanks for any help

May 1st, 2007, 08:11 PM
Use :: with no name in front to refer to the global namespace.

This compiles with g++:

#include <unistd.h>

namespace NS {
int close() {
int fd;
return ::close(fd);