Так что у меня те, в .h
разыменования 'пустота * указатель на C
stable.h
// The symbol table.
typedef struct stable_s *SymbolTable;
// Data stored.
typedef union {
int i;
char *str;
void *p;
} EntryData;
// Return struct for stable_insert.
typedef struct {
int new; // Was a new entry created?
EntryData *data; // Data associated with entry.
} InsertionResult;
etc
Тогда в моей .c
stable.c
etc
typedef struct {
char *key;
EntryData data;
} Entry;
struct stable_s { /* Indice hash */
char index;
int size;
void *pointer;
};
etc
EntryData *stable_find(SymbolTable table, const char *key){
int k;
char c;
if (key[0] >= 'A' && key[0] <= 'Z')
c = table[(key[0] - 65)].index;
else if (key[0] >= 'a' && key[0] <= 'z')
c = table[(key[0] - 141)].index;
else
c = table[26].index;
c -= 65;
if (table[c].size == 0)
return NULL;
k = busca_binaria(table[c].pointer, table[c].size, key);
if (strcmp(table[c]->pointer[k]->key, key) == 0)
return table[c]->pointer[k]->data;
return NULL;
}
И gcc -std=c99 stable.c -o stable
дает мне эти ошибки:
stable2.c: In function ‘stable_find’: stable2.c:128:24: error: invalid type argument of ‘->’ (have ‘struct stable_s’) if (strcmp(table[c]->pointer[k]->key, key) == 0) stable2.c:129:24: error: invalid type argument of ‘->’ (have ‘struct stable_s’) return table[c]->pointer[k]->data;
Что мне не хватает? Я действительно потерялся в синтаксисе.
Что 'SymbolTable'? –
Является ли ваш компилятор '' '' '' '' '' '' '' '' неподписанным '? Из-за этого выражения 'key [0] - 141' –
@EugeneSh .: См. Stable.h выше:' typedef struct stable_s * SymbolTable; ' –