Connecting Tech Pros Worldwide Forums | Help | Site Map

Doubt about open() function used inside a C++ function.

cviniciusm@gmail.com
Guest
 
Posts: n/a
#1: Apr 30 '07
Hello,

I'm using "g++ (GCC) 4.1.1 20070105 (Red Hat 4.1.1-51)".

I'm trying to use the open() function as defined by the header
fcntl.h, but I'm getting this error:
"
mylibrary.cpp:16: error: no matching function for call to
'mylibrary::open(const char*, int)'
mylibrary.cpp:14: note: candidates are: int mylibrary::open()
"

mylibrary.h:
class mylibrary
{
private:
int fd;
...
public:
int open(void);
...
};

mylibrary.cpp:
#include <fcntl.h>
#include "mylibrary.h"
int mylibrary::open(void)
{
fd = open("", O_RDWR | O_NOCTTY | O_NONBLOCK);
...
return 0;
}


How I tell the compiler to use the open() from fcntl.h, please?


TIA,
Vinicius.


Tigera
Guest
 
Posts: n/a
#2: Apr 30 '07

re: Doubt about open() function used inside a C++ function.


On Apr 29, 8:35 pm, cvinici...@gmail.com wrote:
Quote:
Hello,
>
I'm using "g++ (GCC) 4.1.1 20070105 (Red Hat 4.1.1-51)".
>
I'm trying to use the open() function as defined by the header
fcntl.h, but I'm getting this error:
"
mylibrary.cpp:16: error: no matching function for call to
'mylibrary::open(const char*, int)'
mylibrary.cpp:14: note: candidates are: int mylibrary::open()
"
>
mylibrary.h:
class mylibrary
{
private:
int fd;
...
public:
int open(void);
...
>
};
>
mylibrary.cpp:
#include <fcntl.h>
#include "mylibrary.h"
int mylibrary::open(void)
{
fd = open("", O_RDWR | O_NOCTTY | O_NONBLOCK);
...
return 0;
>
}
>
How I tell the compiler to use the open() from fcntl.h, please?
>
TIA,
Vinicius.
Perhaps try to get the compiler to search the namespace just outside
of that?
fd = ::open("", O_RDWR | O_NOCTTY | O_NONBLOCK);

cviniciusm@gmail.com
Guest
 
Posts: n/a
#3: Apr 30 '07

re: Doubt about open() function used inside a C++ function.


On 29 abr, 22:42, Tigera <tig...@rocketmail.comwrote:
Quote:
On Apr 29, 8:35 pm, cvinici...@gmail.com wrote:
>
>
>
Quote:
Hello,
>
Quote:
I'm using "g++ (GCC) 4.1.1 20070105 (Red Hat 4.1.1-51)".
>
Quote:
I'm trying to use the open() function as defined by the header
fcntl.h, but I'm getting this error:
"
mylibrary.cpp:16: error: no matching function for call to
'mylibrary::open(const char*, int)'
mylibrary.cpp:14: note: candidates are: int mylibrary::open()
"
>
Quote:
mylibrary.h:
class mylibrary
{
private:
int fd;
...
public:
int open(void);
...
>
Quote:
};
>
Quote:
mylibrary.cpp:
#include <fcntl.h>
#include "mylibrary.h"
int mylibrary::open(void)
{
fd = open("", O_RDWR | O_NOCTTY | O_NONBLOCK);
...
return 0;
>
Quote:
}
>
Quote:
How I tell the compiler to use the open() from fcntl.h, please?
>
Quote:
TIA,
Vinicius.
>
Perhaps try to get the compiler to search the namespace just outside
of that?
fd = ::open("", O_RDWR | O_NOCTTY | O_NONBLOCK);
Yes, it worked.

Thanks a lot,
Vinicius.

Closed Thread


Similar C / C++ bytes