Parse Error with printf - with source

Rick Sivernell res005ru at gte.net
Mon Jul 23 22:56:13 BST 2001


On Monday 23 July 2001 03:42 pm, you wrote:
> OK... Here is the program I am trying to compile... if I take out the
> printf it compiles perfectly, if I leave it there I get a parse error on
> the line following the printf. However, I can compile the Hello World
> example from the KDevelop project wizard which just does a printf and that
> works perfectly. Does anyone have any suggestions? Thanks.
>
> William Bartholomew
>
> #ifdef HAVE_CONFIG_H
> #include <config.h>
> #endif
>
> #include <stdio.h>
> #include <stdlib.h>
>
> #include <sys/socket.h>
> #include <sys/types.h>
> #include <resolv.h>
> #include <netdb.h>
>
> int main(int argc, char *argv[])
> {
>          printf( "Hello World\n" );
>
>          struct servent *srv = getservbyname("pop3", "tcp");
>          struct sockaddr_in addr;
>          int sd, port;
>
>          port = srv->s_port;
>
>          /*--- create socket ---*/
>          sd = socket(PF_INET, SOCK_STREAM, 0);
>          if ( sd < 0 )
>                  panic("socket");
>
>          /*--- bind port/address to socket ---*/
>          memset(&addr, 0, sizeof(addr));
>          addr.sin_family = AF_INET;
>          addr.sin_port = port;
>          addr.sin_addr.s_addr = INADDR_ANY;                   /* any
> interface */
>          if ( bind(sd, (struct sockaddr*)&addr, sizeof(addr)) != 0 )
>                  panic("bind");
>
>          /*--- make into listener with 10 slots ---*/
>          if ( listen(sd, 10) != 0 )
>                  panic("listen");
>
>          /*--- begin waiting for connections ---*/
>          else
>          {       int sd;
>                  pthread_t child;
>                  FILE *fp;
>
>                  while (1)                         /* process all incoming
> clients */
>                  {
>                          sd = accept(sd, 0, 0);     /* accept connection */
>                          fp = fdopen(sd, "r+");           /* convert into
> FILE* */
>                          fclose( fp );
>                  }
>          }
>
>   return EXIT_SUCCESS;
> }
>
> -
> to unsubscribe from this list send an email to
> kdevelop-request at kdevelop.org with the following body: unsubscribe
> »your-email-address«

add this >>>>    /usr/include/printf.h to your list of includes
-- 
Rick Sivernell
Dallas, Texas  75287
972 306-2296
res005ru at gte.net
Caldera Open Linux eWorkStation 3.1
Registered Linux User

        .~.
       / v \
      /( _ )\
        ^ ^
In Linux we trust!

-
to unsubscribe from this list send an email to kdevelop-request at kdevelop.org with the following body:
unsubscribe »your-email-address«



More information about the KDevelop mailing list