c - Getting a Expected identifier or '(' issue in Xcode 6.1 -


i'm quite new c. i've tried other links no dice.
i'm using xcode 6.1 , following issues:

parse issue: expected identifier or '('
semantic issue: unexpected type name 'map'

here's code:

//hashmap.h   #ifndef __hashmap__hashmap__ #define __hashmap__hashmap__  void map_init(); void map_insert(uint8_t, uint8_t); uint8_t map_getval(uint8_t);  #endif /* defined(__hashmap__hashmap__) */   

//hashmap.c #include <stdint.h> #include "hashmap.h"  #define key_not_found   -1  static int = 0;  typedef struct hashmap {     uint8_t key;     uint8_t val; } *map;  void map_init() {     map = (hashmap*) calloc(1, sizeof(hashmap));                //parse issue }  void map_insert(uint8_t key, uint8_t val) {     int size;     map[i].key = key;                                           //parse issue     map[i].val = val;                                           //parse issue     i++;     size = + 1;     map = (hashmap*) realloc(map, size * sizeof(hashmap));      //parse issue }  int map_search(hashmap map[], uint8_t key) {     int index, size = i;     for(index = 0; index <= size; index++)         if(map[index].key == key)             return index;     return key_not_found; }  uint8_t map_getval(uint8_t key) {     return map[map_search(map, key)].val;                       //semantic issue } 

i tried replacing map[i] pointer array notation (map + i) yields same result. feel free point out how hashmap flop after issues fixed.

change:

typedef struct hashmap {     uint8_t key;     uint8_t val; } *map; 

with:

typedef struct hashmap {     uint8_t key;     uint8_t val; } hashmap ;  hashmap *map; 

Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -