Hello, 

I've looked for this answer on many forums without luck. I'm trying to
compile som code written and compiled on a linux-machine and need to compile
it in Cygwin to port it on a microprocessor. I now that Cygwin is _not_
Linux, but as C is an 'international' language it should work...?

But i get the following compiling with -traditional flag:

$ gcc -traditional irrec.c
/usr/include/asm/ioctl.h:56: warning: "_IO" redefined
/usr/include/asm/ioctl.h:57: warning: "_IOR" redefined
/usr/include/asm/ioctl.h:58: warning: "_IOW" redefined
/usr/include/asm/ioctl.h:69: warning: "IOC_IN" redefined
/usr/include/asm/ioctl.h:70: warning: "IOC_OUT" redefined
/usr/include/asm/ioctls.h:34: warning: "FIONREAD" redefined
/usr/include/asm/ioctls.h:41: warning: "FIONBIO" redefined
/usr/include/asm/ioctls.h:55: warning: "FIOASYNC" redefined
/usr/include/bits/ioctls.h:34: warning: "SIOCGIFCONF" redefined
/usr/include/bits/ioctls.h:35: warning: "SIOCGIFFLAGS" redefined
/usr/include/bits/ioctls.h:37: warning: "SIOCGIFADDR" redefined
/usr/include/bits/ioctls.h:41: warning: "SIOCGIFBRDADDR" redefined
/usr/include/bits/ioctls.h:43: warning: "SIOCGIFNETMASK" redefined
/usr/include/bits/ioctls.h:45: warning: "SIOCGIFMETRIC" redefined
/usr/include/bits/ioctls.h:49: warning: "SIOCGIFMTU" redefined
/usr/include/bits/ioctls.h:54: warning: "SIOCGIFHWADDR" redefined
/usr/include/bits/confname.h:200: macro or #include recursion too deep
/usr/include/sys/features.h:82: warning: "_POSIX_SAVED_IDS" redefined
/usr/include/sys/features.h:83: warning: "_POSIX_VERSION" redefined
/usr/include/sys/signal.h:168: #error You need the winsup sources or a
cygwin in
stallation to compile the cygwin version of newlib.
irrec.c:36: macro or #include recursion too deep

++++++++++++++++++++++++++++++++++++
I'm speechless, I found some posts about the winsup sources but I didn't
quite understand them. I've installed cygwin of the web with _all_
installation options.

Please give me some hints...

For the ones interested, the code I'm trying to compile is:

/* 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 argc, char *argv[])
{
        struct sockaddr_irda peer, self;
        int addrlen;
        int fd, conn_fd;
        FILE *stream;

        printf("Creating socket...");

        /* Create socket */
        fd = socket(AF_IRDA, SOCK_STREAM, 0);
        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*) &self, sizeof(struct
sockaddr_irda))) {
                perror("bind");
                return -1;
        }

        /* Listen if socket fd has more than 8 connections */
        if (listen(fd, 8)) {
                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(buf, sizeof(buf), stream) == NULL) ||
                           (buf[0] == 0x3))
                                buf[0] = '\0';

                        fwrite(buf, 1, strlen(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;
}



--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

Reply via email to