invalid types ‘int[int]’ for array subscript

Greetings

I'm getting a weird compilation fault and don't know why.
Here are the functions:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
int gettactic (int t, int team, int side, int game){
[...](shortened, mysql connection stuff)
	
	/*
	##########################################################
	######################## Taktik ##########################
	##########################################################
	*/
	
	char abfrage[300];
	int mooh=sprintf(abfrage,"SELECT * FROM aufstellung WHERE game='%d' AND team='%d'", game, team);
	mysql_query(connect,abfrage);
	int rc;

	unsigned int i = 0;
	res_set = mysql_store_result(connect);

	unsigned int numrows = mysql_num_rows(res_set);
	
	int vert=4;
	int mf=4;
	int st=2;
	int x=0;
	// Variablen
	int format;
	int tw;
	// This while is to print all rows and not just the first row found,
	while ((row = mysql_fetch_row(res_set)) !=NULL)
	{
		format=atoi(row[2]);
		tw=atoi(row[3]);
		
		int feld1=atoi(row[4]);
		int feld2=atoi(row[5]);
		int feld3=atoi(row[6]);
		int feld4=atoi(row[7]);
		
		int feld5=atoi(row[8]);
		int feld6=atoi(row[9]);
		int feld7=atoi(row[10]);
		int feld8=atoi(row[11]);
		
		int feld9=atoi(row[12]);
		int feld10=atoi(row[13]);
		
	}
	t=getplayers(tw,1,team,side,t);
	printf("Team: %d\nGame: %d\nSystem: %d\nTW: %d\nt: %d\n",team,game,format,tw,t);
	//taktik[team].penalty=t;
	mysql_close(connect); // Close and shutdown	
	return t;
}

calling
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
int getplayers (int player, int pos, int team, int side, int t){
	pthread_attr_init(&attr);
	pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
	//#################################################################
	//######################## MySQL ##################################
	//#################################################################
[...](as before..]

	
	/*
	###########################################################
	######################## Spieler ##########################
	###########################################################
	*/
	char abfrage[300];
	int mooh=sprintf(abfrage,"SELECT * FROM player WHERE id='%d'", player);
	printf("%s",abfrage);
	mysql_query(connect,abfrage);
	int rc;

	unsigned int i = 0; 
	res_set = mysql_store_result(connect);

	unsigned int numrows = mysql_num_rows(res_set);
	
	int vert=4;
	int mf=4;
	int st=2;
	int x=0;
	// This while is to print all rows and not just the first row found,
	while ((row = mysql_fetch_row(res_set)) !=NULL)
	{
		player[t].pid = atoi(row[0]);
		player[t].foot = atoi(row[4]);
		player[t].name = row[3];
		player[t].team = team; //atoi(row[11]);
		
		//player[t].movetox=zufallx();
		//player[t].movetoy=zufally();
				
		player[t].frische = atoi(row[30]);
		player[t].moral = atoi(row[29]);
		player[t].kondition = atoi(row[13]);
		player[t].skill = atoi(row[48]);
		player[t].form = atoi(row[61]);
		
		player[t].passspiel = atoi(row[14]);
		player[t].zweikampf = atoi(row[15]);
		player[t].technik = atoi(row[16]);
		player[t].schnell = atoi(row[17]);
		player[t].kopfb = atoi(row[31]);
		player[t].schusskr = atoi(row[32]);
		player[t].schussg = atoi(row[33]);
		player[t].spielint = atoi(row[34]);
		player[t].stellsp = atoi(row[35]);
		
		player[t].t_reflex = atoi(row[36]);
		player[t].t_parade = atoi(row[37]);
		player[t].t_luft = atoi(row[38]);
		player[t].t_heraus = atoi(row[39]);
		player[t].t_ballsich = atoi(row[40]);
		player[t].side = side;
		player[t].vert = vert;
		player[t].mf = mf;
		player[t].st = st;
		player[t].posnum = x;
		player[t].grosse=atoi(row[112]);
		player[t].aura = (atoi(row[34]) + atoi(row[35]) + atoi(row[17]) + atoi(row[15]))/40;
		player[t].maxpass = ((atoi(row[32]) + (2*(atoi(row[14]))) + atoi(row[33]) + atoi(row[34]) + atoi(row[16]))/12)+10;
		player[t].pos = atoi(row[18]);
		
		player[t].standard=ceil((atoi(row[33])+atoi(row[32])+atoi(row[16])+atoi(row[14]))/40);
		printf("%d",player[t].standard);
		printf("|%s|(%s)[%s][%s cm]\n", row[3], row[18],row[11], row[112]);
		
		if(side==1){
			if(player[t].pos==1){
				player[t].posx=11;
			}
			else if(player[t].pos==2){
				player[t].posx=25;
			}
			else if(player[t].pos==3){
				player[t].posx=45;
			}
			else{
				player[t].posx=50;
			}
		}else if(side==2){
			if(atoi(row[18])==1){
				player[t].posx=89;
			}
			else if(atoi(row[18])==2){
				player[t].posx=75;
			}
			else if(atoi(row[18])==3){
				player[t].posx=55;
			}
			else if(atoi(row[18])==4){
				player[t].posx=50;
			}
		}
		
		rc = pthread_create(&threads[t], &attr, poschecks, (void *) &player[t]);
		t++;
		x++;
	}
	printf("--------------\n");
	mysql_close(connect); // Close and shutdown	
	return t;
}


And here is the GCC output:
1
2
3
4
5
6
7
8
engine.cc: In function ‘int getplayers(int, int, int, int, int)’:
engine.cc:2417: error: invalid types ‘int[int]’ for array subscript
engine.cc:2418: error: invalid types ‘int[int]’ for array subscript
engine.cc:2419: error: invalid types ‘int[int]’ for array subscript
engine.cc:2420: error: invalid types ‘int[int]’ for array subscript
engine.cc:2425: error: invalid types ‘int[int]’ for array subscript
[...]
engine.cc:2488: error: invalid types ‘int[int]’ for array subscript


each "player[t]." gets this error.

player_data player[NUM_THREADS];

Anyone an idea?
looks like a function definition error, not a call error. can you post the first lines of your definitions? (ex: void function(int [], double, char);)
#define NUM_THREADS 22
EDIT:
*************************************
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
struct player_data{
	int thread_id;
	int pid;
	int foot;
	int pos;
	int side;
	int team;
	
	// taktisches
	int ausr_team;
	int ausr_pos;
	int ausr;
	
	int xmin;
	int xmax;
	int ymin;
	int ymax;
	
	int moveplayerp;
	
	int vert;
	int mf;
	int st;
	
	int posnum;
	int aura;
	// skillwerte & stats
	int maxpass;
	int karma;
	int aktionen;
	int playerlock;
	int status;
	int standard;
	int grosse;
	
	// skills
	int passspiel;
	int zweikampf;
	int technik;
	int schnell;
	int kopfb;
	int schusskr;
	int schussg;
	int spielint;
	int stellsp;	
	
	int t_reflex;
	int t_parade;
	int t_luft;
	int t_heraus;
	int t_ballsich;
	
	int frische;
	int moral;
	int kondition;
	int skill;
	int form;
	
	int movetox;
	int movetoy;
	int posx;
	int posy;
	int hasball;
	char *name;
	// ######################
	// ### Statistikwerte ###
	// ######################
	// Gelaufene Distanz
	int rundist;
	// Zweikämpfe
	int zkwon;
	int zklost;
};

*********************************
player_data player[NUM_THREADS]; int getplayers (int player, int pos, int team, int side, int t) int gettactic (int t, int team, int side, int game)

In this order, with other functions in between.

main() calls gettactic:

t=gettactic (t, 1, 1, 5153);
Anything else you want to see? (Thanks beforhand)
Last edited on
in any of your function definitions, are you using arrays? when you declare an array you can't forget the [] in the definition. in the call you don't need the brackets as it will read as a variable.

so for example, if in getplayers(), if player is an array, it should be declared like:

int getplayers (int player[], int pos, int team, int side, int t);
not
int getplayers (int player, int pos, int team, int side, int t)


that could be what's causing your problem
oh I'm so stupid. I've overridden the player array, defined with the structure. With the player id. Thanks kenner =)
Topic archived. No new replies allowed.