#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2003
    Posts
    2
    Rep Power
    0

    Problem compiling in Cygwin


    Hi, having trouble compiling basic irda code ported from Linux to Cygwin under Win2000.

    I get this when running in traditional mode:

    $ gcc -traditional irrec.c
    /usr/include/sys/types.h:157: parse error
    /usr/include/sys/socket.h:65: parse error
    /usr/include/sys/cdefs.h:31: #error "You need a ISO C conforming compiler to use
    the glibc headers"
    /usr/include/sys/cdefs.h:43: parse error
    /usr/include/sys/cdefs.h:122: parse error
    /usr/include/sys/cdefs.h:173: parse error
    /usr/include/sys/cdefs.h:182: parse error
    /usr/include/sys/cdefs.h:191: parse error
    /usr/include/sys/cdefs.h:205: parse error
    /usr/include/sys/cdefs.h:215: parse error
    /usr/include/sys/cdefs.h:226: parse error
    /usr/include/sys/cdefs.h:231: parse error
    /usr/include/sys/cdefs.h:238: parse error
    /usr/include/sys/signal.h:168: #error You need the winsup sources or a cygwin in
    stallation to compile the cygwin version of newlib.

    For example Row 43 in cdefs.h: # if defined __cplusplus && __GNUC_PREREQ (2,8)
    Row 122: #if __GNUC_PREREQ (2,97)

    And this when running "normal" mode:

    $ gcc irrec.c
    In file included from /usr/include/sys/uio.h:24,
    from /usr/include/sys/socket.h:27,
    from irrec.c:3:
    /usr/include/sys/types.h:28: parse error before "__BEGIN_DECLS"
    In file included from /usr/include/bits/types.h:29,
    from /usr/include/sys/types.h:30,
    from /usr/include/sys/uio.h:24,
    from /usr/include/sys/socket.h:27,
    from irrec.c:3:
    /usr/lib/gcc-lib/i686-pc-cygwin/3.2/include/stddef.h:203: syntax error before "t
    ypedef"
    In file included from /usr/include/sys/types.h:132,
    from /usr/include/sys/uio.h:24,
    from /usr/include/sys/socket.h:27,
    from irrec.c:3:
    /usr/include/time.h:46: parse error before "clock"
    /usr/include/time.h:47: parse error before "_time2"
    /usr/include/time.h:48: parse error before "mktime"
    /usr/include/time.h:49: parse error before "time"
    /usr/include/time.h:52: parse error before '*' token
    /usr/include/time.h:53: parse error before '*' token
    /usr/include/time.h:54: parse error before '*' token
    /usr/include/time.h:59: parse error before '*' token
    /usr/include/time.h:60: parse error before '*' token
    /usr/include/time.h:61: parse error before '*' token
    /usr/include/time.h:98: parse error before "_timezone"
    In file included from /usr/include/sys/uio.h:24,
    from /usr/include/sys/socket.h:27,
    from irrec.c:3:
    /usr/include/sys/types.h:157:20: missing binary operator before '('
    In file included from /usr/include/sys/socket.h:27,
    from irrec.c:3:
    /usr/include/sys/uio.h:26: parse error before "__BEGIN_DECLS"
    In file included from /usr/include/sys/socket.h:27,
    from irrec.c:3:
    /usr/include/sys/uio.h:37: syntax error before "extern"
    /usr/include/sys/uio.h:38: parse error before "__THROW"
    /usr/include/sys/uio.h:46: parse error before "__THROW"
    In file included from irrec.c:3:
    /usr/include/sys/socket.h:49: syntax error before "enum"
    In file included from irrec.c:3:
    /usr/include/sys/socket.h:65:43: missing binary operator before '('
    /usr/include/sys/socket.h:100: parse error before "__THROW"
    /usr/include/sys/socket.h:107: parse error before "__THROW"
    /usr/include/sys/socket.h:110: parse error before "socklen_t"
    /usr/include/sys/socket.h:115: parse error before "socklen_t"
    /usr/include/sys/socket.h:121: parse error before "socklen_t"
    /usr/include/sys/socket.h:127: parse error before "socklen_t"
    /usr/include/sys/socket.h:132: parse error before "__THROW"
    /usr/include/sys/socket.h:137: parse error before "__THROW"
    /usr/include/sys/socket.h:143: parse error before "socklen_t"
    /usr/include/sys/socket.h:150: parse error before "socklen_t"
    /usr/include/sys/socket.h:157: parse error before "__THROW"
    /usr/include/sys/socket.h:162: parse error before "__THROW"
    /usr/include/sys/socket.h:170: parse error before "socklen_t"
    /usr/include/sys/socket.h:176: parse error before "socklen_t"
    /usr/include/sys/socket.h:182: parse error before "__THROW"
    /usr/include/sys/socket.h:190: parse error before "socklen_t"
    /usr/include/sys/socket.h:199: parse error before "__THROW"
    In file included from /usr/include/sys/select.h:17,
    from /usr/include/sys/time.h:31,
    from irrec.c:5:
    /usr/include/sys/cdefs.h:43:43: missing binary operator before '('
    /usr/include/sys/cdefs.h:122:19: missing binary operator before '('
    /usr/include/sys/cdefs.h:173:19: missing binary operator before '('
    /usr/include/sys/cdefs.h:182:19: missing binary operator before '('
    /usr/include/sys/cdefs.h:191:19: missing binary operator before '('
    /usr/include/sys/cdefs.h:205:19: missing binary operator before '('
    /usr/include/sys/cdefs.h:215:19: missing binary operator before '('
    /usr/include/sys/cdefs.h:226:20: missing binary operator before '('
    /usr/include/sys/cdefs.h:231:20: missing binary operator before '('
    /usr/include/sys/cdefs.h:238:19: missing binary operator before '('
    In file included from /usr/include/sys/time.h:31,
    from irrec.c:5:
    /usr/include/sys/select.h:28: syntax error before "int"
    /usr/include/sys/select.h:29: parse error before "fd_set"
    In file included from irrec.c:5:
    /usr/include/sys/time.h:111: field `it_interval' has incomplete type
    /usr/include/sys/time.h:113: field `it_value' has incomplete type
    In file included from /usr/include/signal.h:5,
    from irrec.c:12:
    /usr/include/sys/signal.h:168:6: #error You need the winsup sources or a cygwin
    installation to compile the cygwin version of newlib.
    In file included from /usr/include/signal.h:5,
    from irrec.c:12:
    /usr/include/sys/signal.h:171: parse error before "thread"
    In file included from irrec.c:17:
    /usr/include/linux/types.h:10: syntax error before "dev_t"
    /usr/include/linux/types.h:11: syntax error before "ino_t"
    /usr/include/linux/types.h:12: syntax error before "mode_t"
    /usr/include/linux/types.h:13: syntax error before "nlink_t"
    /usr/include/linux/types.h:14: syntax error before "off_t"
    /usr/include/linux/types.h:15: syntax error before "pid_t"
    /usr/include/linux/types.h:16: parse error before "daddr_t"
    /usr/include/linux/types.h:18: syntax error before "suseconds_t"
    /usr/include/linux/types.h:20: syntax error before "uid_t"
    /usr/include/linux/types.h:21: syntax error before "gid_t"
    /usr/include/linux/types.h:25: syntax error before "loff_t"
    /usr/include/linux/types.h:39: syntax error before "ssize_t"
    /usr/include/linux/types.h:44: parse error before "ptrdiff_t"
    /usr/include/linux/types.h:49: parse error before "time_t"
    /usr/include/linux/types.h:54: parse error before "clock_t"
    /usr/include/linux/types.h:59: parse error before "caddr_t"
    /usr/include/linux/types.h:104: parse error before "__kernel_daddr_t"
    /usr/include/linux/types.h:108: parse error before '}' token
    In file included from irrec.c:18:
    /usr/include/linux/irda.h:109: parse error before "sa_family_t"
    /usr/include/linux/irda.h:113: parse error before '}' token
    irrec.c: In function `main':
    irrec.c:28: storage size of `peer' isn't known
    irrec.c:28: storage size of `self' isn't known
    irrec.c:36: `SOCK_STREAM' undeclared (first use in this function)
    irrec.c:36: (Each undeclared identifier is reported only once
    irrec.c:36: for each function it appears in.)
    irrec.c:51: sizeof applied to an incomplete type
    irrec.c:63: sizeof applied to an incomplete type

    This is compiling fine under Linux kernel 2.4.20 etc.

    Please help?!
  2. #2
  3. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2003
    Posts
    2
    Rep Power
    0

    Please


    Please, any ideas?!

    Is it somehow connected to the compiler flags?

    This is C-code straight out of a Linux machine, should be the same...right?

    Regards!


    The code is submitted below:

    PHP Code:
    /* Read an IR socket and display it on stdout */

    #include <sys/socket.h>
    #include <sys/types.h>
    #include <sys/time.h>
    #include <sys/ioctl.h>
    #include <sys/stat.h>

    #include <unistd.h>
    #include <stdio.h>
    #include <stdlib.h>
    #include <signal.h>
    #include <string.h>
    #include <fcntl.h>
    #include <errno.h>

    #include <linux/types.h>
    #include <linux/irda.h>

    #ifndef AF_IRDA
    #define AF_IRDA 23
    #endif /* AF_IRDA */

    unsigned char buf[4098];

    int main(int argcchar *argv[])
    {
        
    struct sockaddr_irda peerself;
        
    int addrlen;
        
    int fdconn_fd;
        
    FILE *stream;

        
    printf("Creating socket...");

        
    /* Create socket */
        
    fd socket(AF_IRDASOCK_STREAM0);
        if (
    fd 0
        {
            
    perror("socket");
            exit(-
    1);
            }
        
    printf("successful!\n");

        
    /* Initiate receiver */
        
    self.sir_family AF_IRDA//Serial IR
        
    strncpy(self.sir_name"MyServer"25); //Rename to "MyServer"

        
    self.sir_lsap_sel LSAP_ANY//Select any LSAP: IAS asks secondary which port (LSAP-SEL)
        
        /* Bind name "MyServer" to socket fd */
        
    if (bind(fd, (struct sockaddr*) &selfsizeof(struct sockaddr_irda))) {
            
    perror("bind");
            return -
    1;
        }

        
    /* Listen if socket fd has more than 8 connections */
        
    if (listen(fd8)) {
            
    perror("listen");
            return -
    1;
        }

        for (;;) {
            
    addrlen sizeof(struct sockaddr_irda);

            
    printf("Any connections?\n");

            
    /* Accepting connection if any present and bound, listened. Creates a new socket with same prop. as fd */
            
    conn_fd accept(fd, (struct sockaddr *) &peer, &addrlen);
            if (
    conn_fd 0) {             //Non-negative integer for success (decriptor for accepted socket)
                
    perror("accept");
                return -
    1;
            }
            
    stream fdopen(conn_fd"r"); //opens and reads conn_fd and streams it to file "stream"
            
    if(stream == NULL) {
                
    perror("fdopen");
                return -
    1;
            }
            
    printf("Connected!\n");
                
            do {
                if((
    fgets(bufsizeof(buf), stream) == NULL) ||
                   (
    buf[0] == 0x3))
                    
    buf[0] = '\0';

                
    fwrite(buf1strlen(buf), stdout); //writes 1 char at the time to stdout from buf until EOF

            
    } while (buf[0] != '\0');
            
    fflush(stdout); //forces a write from stdout
            
    fclose(stream); //dissociates stream from underlying set of functions
            
    printf("\n%d\n",conn_fd);
            
    close(conn_fd); //closing file descriptor fd
            
    printf("Disconnected!\n");
        }
        return 
    0;


IMN logo majestic logo threadwatch logo seochat tools logo