Hi Folks,
I want to wrap the Unix socket library in a C++ class and am having the
following difficulty. I have a method in my C++ class named connect and
within this method I want to call the Unix socket connect function. The
problem is that the compiler complains:
.../common/Socket.h:71: error: no matching function for call to
âSocket::connect(int&, sockaddr*&, int&)â
.../common/Socket.h:37: note: candidates are: void Socket::connect(const
char*, int)
Notice that it is looking within my Socket class for connect(int, sockaddr,
int), but it really should be looking in the C-based socket library. What
I've done as a kludgy fix is to create a forwarding function:
fConnect(int, sockaddr, int) {
connect(int, sockaddr, int);
}
class Socket {
connect() {
fConnect(int, sockaddr, int);
}
}
But I find this to be ugly. Is there a better way to accomplish this,
perhaps my simply specifying which connect I want to call within the class,
instead of having to deal with renaming things?
Thank you. 4 2426
Anonymous wrote:
class Socket {
connect() {
fConnect(int, sockaddr, int);
}
}
This has nothing to do with connect being a C function.
It has entirely everything to do with names in different
scopes. Inside Socket::connect() the lookup yields
Socket::connect(). If you want the global namespace
connect, all you do is add the scope resolution operator:
connect() {
::connect(int, sockaddr, int);
}
On Thu, 28 Sep 2006 06:14:31 -0500, "Anonymous" <An*******@home.net>
wrote:
>Hi Folks,
I want to wrap the Unix socket library in a C++ class and am having the following difficulty. I have a method in my C++ class named connect and within this method I want to call the Unix socket connect function.
<...>
> class Socket {
connect() {
fConnect(int, sockaddr, int);
use instead:
::connect(int,sockaddr,int);
} }
This tells the compiler tyo look for connect at the global scope.
Once you have corrected all errros that will arise from trying to use
the token "int" as parameter to call a function and some similiar
ones... you will have your connect function working.
Zara
Anonymous wrote:
Hi Folks,
I want to wrap the Unix socket library in a C++ class and am having the
following difficulty. I have a method in my C++ class named connect and
within this method I want to call the Unix socket connect function. The
problem is that the compiler complains:
../common/Socket.h:71: error: no matching function for call to
âSocket::connect(int&, sockaddr*&, int&)â
../common/Socket.h:37: note: candidates are: void Socket::connect(const
char*, int)
Notice that it is looking within my Socket class for connect(int, sockaddr,
int), but it really should be looking in the C-based socket library. What
I've done as a kludgy fix is to create a forwarding function:
fConnect(int, sockaddr, int) {
connect(int, sockaddr, int);
}
class Socket {
connect() {
fConnect(int, sockaddr, int);
}
}
But I find this to be ugly. Is there a better way to accomplish this,
perhaps my simply specifying which connect I want to call within the class,
instead of having to deal with renaming things?
Yes, explcitly qualify the socket's connect function as being in the
global namespace:
::connect( someInt, someAddr, someOtherInt );
Cheers! --M
Anonymous wrote:
Hi Folks,
I want to wrap the Unix socket library in a C++ class and am having the
following difficulty. I have a method in my C++ class named connect and
within this method I want to call the Unix socket connect function.
try ::connect() to call the global function.
-Martin This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Roy Smith |
last post by:
I've got a C library with about 50 calls in it that I want to wrap in
Python. I know I could use some tool like SWIG, but that will give me a
too-literal translation; I want to make some...
|
by: nimdez |
last post by:
Hi,
I am working on an existing code base in which a lot of data displayed
to the user is formatted in tables. Most tables are printed row-by-row
using printf() with "%s" print conversion...
|
by: dam_fool_2003 |
last post by:
My understanding about wrapping is that we add utilities to a lib
function for our specific use. So days ago in the c.l.c I saw a
function def as:
void *
xmalloc (size_t size)
{
register void...
|
by: John Lee |
last post by:
Hi,
I understand we could use p/Invoke to access most of the C/C++ DLL but there
are some cases the functions can only be accessed by C/C++ so it would be
good if I could create a .NET class to...
|
by: Lee Crabtree |
last post by:
More fun wrapping unmanaged code...
I have a class heirarchy that I need to expose to C#, so I need to wrap all
the classes. That's not a big deal, except for the base class, which is
abstract....
|
by: Tom the Canuck |
last post by:
What would be the best way to proceed?
Should I make a pure virtual class and then
derive from that? I want the base class to have
functions defined so that I don't have to do the
work all over...
|
by: Gerhard Prilmeier |
last post by:
Hello,
I have an unmanaged C++ API that uses virtual functions, like this:
class A
{
public:
virtual void handleMe(){}
};
|
by: gabriel.becedillas |
last post by:
Hi,
I'm having problems wrapping a hierarchy of classes, actually having
problems wrapping the base class. I don't need to use the WrapClass
mechanism since I don't want to override classes in...
|
by: Anish Chapagain |
last post by:
Hi!!
I tried wrapping a simple C code suing SWIG to Python, but am having
problem,
my .c file is,
Step 1:
example.c
--------------
double val=3.0;
int fact(int n)
|
by: Charlie |
last post by:
Hi All,
I am new to using swig/C++/python. I got some problem with function
pointers. I posted in swig-user, but got no response. So I forwarded
it here. You help is greatly appreciated.
...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |