Doubt about open() function used inside a C++ function.
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Unix and Linux reviews > Free Unix support > Unix Programming > Doubt about open() function used inside a C++ function.




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    Doubt about open() function used inside a C++ function.  
cviniciusm@gmail.com


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
04-30-07 06:17 AM

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("/dev/ttyS0", O_RDWR | O_NOCTTY | O_NONBLOCK);
..
return 0;

}

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

TIA,
Vinicius.






[ Post a follow-up to this message ]



    Re: Doubt about open() function used inside a C++ function.  
sam_cit@yahoo.co.in


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
04-30-07 06:17 AM

On Apr 30, 6:55 am, cvinici...@gmail.com wrote:
> 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("/dev/ttyS0", O_RDWR | O_NOCTTY | O_NONBLOCK);
>    ...
>    return 0;
>
> }
>
> How to tell the compiler to use the open() from fcntl.h, please?
>
> TIA,
> Vinicius.

any reason as to why you are having the same name open() for your
custom member function of the class?






[ Post a follow-up to this message ]



    Re: Doubt about open() function used inside a C++ function.  
Barry Margolin


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
04-30-07 06:17 AM

In article <1177898133.107010.322600@y80g2000hsf.googlegroups.com>,
cviniciusm@gmail.com wrote:

> 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("/dev/ttyS0", O_RDWR | O_NOCTTY | O_NONBLOCK);
>    ...
>    return 0;
>
> }
>
> How to tell the compiler to use the open() from fcntl.h, please?

fd = ::open(...);

--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***





[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 06:38 PM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register