This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Linux Socket Help


A more appropriate place to ask these questions would be
comp.unix.programmer; this mailing list is intended for the development of
gcc rather than for general questions.

Here are the answers that I know off the top of my head; you may want to
follow up in the newsgroup if you have additional more detailed questions.

Ryan Gilfether <rgilfeth@gmu.edu> writes:

> I am having trouble with the accept() funtion. The book I am using for
> help shows that the accept function takes 3 parameters:

> accept(int s, struct sockaddr *addr, int *addrlen);

> I get a compilation error saying "passing 'int *' as argument 3 of
> 'accept(int, sockaddr*, socklen_t *)' changes signedness"

The type of the third argument of accept() varies between different
operating systems.  socklen_t * is now the standard type, but the standard
is relatively new.  accept() requires that the headers <sys/types.h> and
<sys/socket.h> be included, so if socklen_t is defined on your platform,
it will be defined in one of those two header files or a header file
included by them.

You cannot yet portably assume that a platform will have socklen_t; if you
want to use it, you have to test for it using something like autoconf.
Alternately, you can just use an int * and ignore the warnings; on most
platforms, this will work.

> Also what is the difference between gcc and g++,

gcc and g++ are both programs included in the GNU Compiler Collection.
gcc is a C compiler; g++ is a C++ compiler.  You should compile C++ code
using g++.

> i thought gcc was both a c++ and c compiler.

They both come as part of the same software package, but there are
different front-end executables.

-- 
Russ Allbery (rra@stanford.edu)             <http://www.eyrie.org/~eagle/>

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]