Ok I hate C.... Compilation Problems with gcc, Please help if you can

cchen

Diamond Member
Oct 12, 1999
6,062
0
76
I'm having some issues compiling the file with gcc (but it compiles with codewarrior). The errors are :

In file included from data.c:10:
/usr/include/string.h: In function `clearMem':
/usr/include/string.h:39: storage class specified for parameter `memcpy'
/usr/include/string.h:43: storage class specified for parameter `memmove'
/usr/include/string.h:52: storage class specified for parameter `memccpy'
/usr/include/string.h:58: storage class specified for parameter `memset'
/usr/include/string.h:62: storage class specified for parameter `memcmp'
/usr/include/string.h:66: storage class specified for parameter `memchr'
/usr/include/string.h:83: storage class specified for parameter `strcpy'
/usr/include/string.h:86: storage class specified for parameter `strncpy'
/usr/include/string.h:90: storage class specified for parameter `strcat'
/usr/include/string.h:93: storage class specified for parameter `strncat'
/usr/include/string.h:97: storage class specified for parameter `strcmp'
/usr/include/string.h:100: storage class specified for parameter `strncmp'
/usr/include/string.h:104: storage class specified for parameter `strcoll'
/usr/include/string.h:107: storage class specified for parameter `strxfrm'
/usr/include/string.h:126: storage class specified for parameter `strdup'
/usr/include/string.h:162: storage class specified for parameter `strchr'
/usr/include/string.h:164: storage class specified for parameter `strrchr'
/usr/include/string.h:177: storage class specified for parameter `strcspn'
/usr/include/string.h:181: storage class specified for parameter `strspn'
/usr/include/string.h:184: storage class specified for parameter `strpbrk'
/usr/include/string.h:187: storage class specified for parameter `strstr'
/usr/include/string.h:192: storage class specified for parameter `strtok'
/usr/include/string.h:199: storage class specified for parameter `__strtok_r'
/usr/include/string.h:202: storage class specified for parameter `strtok_r'
/usr/include/string.h:230: storage class specified for parameter `strlen'
/usr/include/string.h:243: storage class specified for parameter `strerror'
/usr/include/string.h:248: storage class specified for parameter `strerror_r'
/usr/include/string.h:253: storage class specified for parameter `__bzero'
/usr/include/string.h:257: storage class specified for parameter `bcopy'
/usr/include/string.h:260: storage class specified for parameter `bzero'
/usr/include/string.h:264: storage class specified for parameter `bcmp'
/usr/include/string.h:267: storage class specified for parameter `index'
/usr/include/string.h:270: storage class specified for parameter `rindex'
/usr/include/string.h:274: storage class specified for parameter `ffs'
/usr/include/string.h:288: storage class specified for parameter `strcasecmp'
/usr/include/string.h:292: storage class specified for parameter `strncasecmp'
/usr/include/string.h:310: storage class specified for parameter `strsep'
In file included from data.c:11:
/usr/include/stdlib.h:99: storage class specified for parameter `div_t'
/usr/include/stdlib.h:107: storage class specified for parameter `ldiv_t'
/usr/include/stdlib.h:137: storage class specified for parameter `__ctype_get_mb_cur_max'
/usr/include/stdlib.h:142: storage class specified for parameter `atof'
/usr/include/stdlib.h:144: storage class specified for parameter `atoi'
/usr/include/stdlib.h:146: storage class specified for parameter `atol'
/usr/include/stdlib.h:152: parse error before "__extension__"
/usr/include/string.h:38: parm types given both in parmlist and separately
In file included from /usr/include/sys/types.h:216,
from /usr/include/stdlib.h:416,
from data.c:11:
/usr/include/sys/select.h: At top level:
/usr/include/sys/select.h:38: parse error before "sigset_t"
In file included from data.c:11:
/usr/include/stdlib.h:447: parse error before "int32_t"
/usr/include/stdlib.h:449: parse error before '*' token
/usr/include/stdlib.h:453: parse error before '*' token
/usr/include/stdlib.h:454: parse error before '}' token
/usr/include/stdlib.h:457: parse error before "int32_t"
In file included from data.c:11:
/usr/include/stdlib.h:756: parse error before "div"
/usr/include/stdlib.h:758: parse error before "ldiv"
data.c:253: redefinition of `clearMem'
/usr/include/stdlib.h:152: `clearMem' previously defined here

data.c:10: is #include <string.h>
data.c:11: is #include <stdlib.h>

Any ideas on what the issue here is? Seems to be something with string.h and stdlib.h
 

cchen

Diamond Member
Oct 12, 1999
6,062
0
76
lines 1-9:

/*
* my name
* my email
* CS 3157
* HW 2
* data.c */

#include <stdio.h>
#include "data.h"
 

cchen

Diamond Member
Oct 12, 1999
6,062
0
76
But it compiles in Codewarrior and I've ran the project........

Here's the contents of data.h:

/*
* my name
* my email
* CS 3157
* HW 2
* data.h */

typedef struct {

char *question;
char *answer;
} game2;

typedef struct {

game2 *games[5];
} game;

typedef struct {

char *begin;
char *end;
int questionsasked;
int statistics[5];
// 0 for incorrect, 1 for correct
} player_game;

typedef struct {

char *username;
char *password;
int numgames;
player_game *played[999];
} player;

typedef struct {

int numplayers;
player *player2[999];
} players;

/********* FUNCTION HEADERS**********************/
void printgame(game *thegame);
void printplayers (players *theplayers);
game* readgame();
player* getplayer(char *name, players *playerlist);
int login(players *playerlist);
void readFile(players *playerlist);
void clearMem(players *playerlist, game *gamedata)
 

Barnaby W. Füi

Elite Member
Aug 14, 2001
12,343
0
0
At first glance I notice there is no semicolon after the last clearMem.

Simplest way to troubleshoot is to make a simple blah.c file like this and compile it:

#include "data.h"
int main(void) { return 0; }
 

cchen

Diamond Member
Oct 12, 1999
6,062
0
76
AHHH! the semicolon! stupid codewarrior letting me get away with that
thanks!