Question

I have a piece of code that I used to run without problems. But now I'm going back to it and I just can't even compile it!

The piece that is not compiling is a .c file and I think it's complaining about libraries.

I try to compile it by doing this:

gcc f.c 

And I get:

In file included from /usr/include/machine/ansi.h:39:0,
                 from /usr/include/sys/ansi.h:35,
                 from /usr/include/stdio.h:42
                 from f.c:7:
/usr/include/machine/int_types.h:45:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'typedef'
In file included from /usr/include/sys/inttypes.h:39:0,
                 from /usr/include/inttypes.h:36,
                 from /usr/include/netdb.h:98,
                 from f.c:9:
/usr/include/sys/stdint.h:39:18: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'int8_t'
In file included from /usr/include/ara/inet.h:69:0,
                 from netlib.h:7,
                 from f.c:16:
/usr/include/netinet/in.h:242:2: error: expected specifier-qualifier-list before '__int8_t'
/usr/include/netinet/in.h:259:2: error: expected specifier-qualifier-list before '__int8_t'

And this is my .c file:

#include <stdio.h>
#include <string.h>
#include <netdb.h>
#include <sys/socket.h>
#include <unistd.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include "netlib.h"


#include <stdlib.h>

#define MACHSIZE    50
#define BUFFSIZE    256
#define MAXCONN     100
#define MAXFILES    500
#define COMBUFF     200

struct Connection{
        int conn;
    in_addr_t ip;
    int port;
    int numFilesOpened;
};

typedef struct Connection Connection;

Connection connection[MAXCONN];

struct Files{
    int fid;
    long machine;
    int conn;
};

typedef struct Files Files;

Files files[MAXFILES];
int filesOpened = 0;
int port = 15061;
int numCli = 0;
char command[COMBUFF];
char response;
int conn;
char buffer[BUFFSIZE];

... 

There is more to it but I think it has to do with the libraries so you might be able to help me with this.

Can anybody see anything here?

Also, in case this is important, I'm doing this on NetBSD but I tried on FreeBSD and it's the same.

Was it helpful?

Solution

Very mysterious.

Your error messages like "from rfa_cli.c:7:" imply there are 6 lines of code before the "first" line "#include ..." of your C file . Maybe there is some issue with your editor that is hiding these lines - some stray line ending or something. Recommend try compiling with only the "#include ..." in your file to see if the first error still occurs. If is does, start over with a clean text file.

Further, you say you are compiling "f.c", but the error messages say "rfa_cli.c". Please elaborate.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top