title: C4013: undefined; assuming extern returning int
body: <p>I am trying to create malloc function and in this code:</p>
  
  <pre><code>typedef struct hlavicka
  {
    unsigned int velkost;
    struct hlavicka *dalsi;
    struct hlavicka *pred;
  } HLAVICKA;
  
  struct hlavicka *blok;
  
  void init(void *ptr, unsigned size)
  {
    blok = ptr;
    blok-&gt;velkost = 1;
    blok-&gt;dalsi = blok;
    blok-&gt;pred = blok;
  }
  
  void *memory_alloc(unsigned int size)
  {
    HLAVICKA *ptr = NULL;
    int nova_velkost = size + sizeof(HLAVICKA);
    ptr = find_fit(nova_velkost);
    if ((long)ptr == -1)
        return NULL;
    else
    {
        *(unsigned int *)ptr = size;
        return (void *)((char*)ptr + sizeof(HLAVICKA));
    }
  }
  
  void *find_fit(unsigned int size)
  {
    HLAVICKA *pom_ptr;
    for (pom_ptr = blok-&gt;dalsi; (pom_ptr != blok) &amp;&amp; (pom_ptr-&gt;velkost &lt; size); pom_ptr = pom_ptr-&gt;dalsi)
        if (pom_ptr != blok)
          return pom_ptr;
  }
  
  int main()
  {
    char region[50], *pointer;
    init(region, 50);
  
    pointer = (char*)memory_alloc(10);
  
    return 0;
  }
  </code></pre>
  
  <p>I have a three errors:</p>
  
  <pre><code>warning C4013: 'find_fit' undefined; assuming extern returning int
  warning C4047: '=' : 'HLAVICKA *' differs in levels of indirection from 'int'
  error C2040: 'find_fit' : 'HLAVICKA *(unsigned int)' differs in levels of indirection from 'int ()'
  </code></pre>
  
  <p>Where is the problem? In struct or function type?</p>