Parse Error with printf - with source

William Bartholomew william at nsi.net.au
Mon Jul 23 21:42:07 BST 2001


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«



More information about the KDevelop mailing list