title: VS17 not initializing pointer
body: <p>My problem is that this code is not working in VS 2017 while in CLion it works.
  VS says:</p>
  
  <blockquote>
    <p>Severity  Code    Description Project File    Line    Suppression State
    Error (active)  E0144<br>
    a value of type <code>void *</code> cannot be used to initialize an entity of type <code>queue_t*</code></p>
  </blockquote>
  
  <p>therefor the program is not allocating the memory.</p>
  
  <p>Further every pointer like the example above is not working.</p>
  
  <p>Does somebody here know why that is the case, why VS thinks that this would be a <code>void</code>?</p>
  
  <pre><code>#include "stdafx.h"
  #include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;time.h&gt;
  #include &lt;math.h&gt;
  
  struct packet_t {
      double d;
      int i;
      long l;
      char *p;
      struct queue_t *queue;
  };
  
  struct queue_t {
      char *name;
      int size;
      int entries;
      double time;
      struct packet_t **packets;
      int read;
      int write;
      long lost;
      long total;
  };
  
  
  int decision = -1;
  int isRunning = 1;
  
  void logError(char message[]) {
      printf("ERROR: %s", message);
  }
  
  struct queue_t *queue_create(char *name, int size) {
      struct queue_t *q = malloc(sizeof(struct queue_t));
  
      if (!q) {
          logError("could not allocate memory!\n");
          return 0;
      }
      else {
          q-&gt;name = name;
          q-&gt;size = size;
          q-&gt;entries = 0;
          q-&gt;read = 0;
          q-&gt;write = 0;
          q-&gt;total = 0;
          q-&gt;lost = 0;
  
          q-&gt;packets = malloc(size * sizeof(struct packet_t *));
  
          if (!q-&gt;packets) {
              logError("could not allocate memory!\n");
              free(q);
              return 0;
          }
  
          struct packet_t **current;
          for (int i = 0; i &lt; size; i++) {
              current = q-&gt;packets + i;
              *current = NULL;
          }
      }
      return q;
  }
  
  int packet_destroy(struct packet_t *packet) {
      //TODO test if deleted ?
      if (packet) {
          free(packet);
          return 1;
      }
      return 0;
  }
  
  long queue_store(struct queue_t *queue, struct packet_t *packet) {
      if (queue-&gt;entries &lt; queue-&gt;size) {
          packet-&gt;queue = queue;
          *(queue-&gt;packets + queue-&gt;write) = packet;
  
          queue-&gt;write++;
  
          if (queue-&gt;write == queue-&gt;size) {
              queue-&gt;write = 0;
          }
  
          queue-&gt;total++;
          queue-&gt;entries++;
  
          return queue-&gt;total;
      }
      //cant save packet -&gt;destroy
      packet_destroy(packet);
      queue-&gt;lost++;
      return 0;
  }
  
  struct packet_t *queue_retrieve(struct queue_t *queue) {
      if (queue-&gt;entries == 0) return NULL;
  
      struct packet_t **current = queue-&gt;packets + queue-&gt;read;
      struct packet_t *packet = *current;
  
      *current = NULL;
      if (packet-&gt;queue) {
          packet-&gt;queue = NULL;
      }
      queue-&gt;entries--;
  
      queue-&gt;read++;
      if (queue-&gt;read == queue-&gt;size) {
          queue-&gt;read = 0;
      }
  
      return packet;
  }
  
  struct packet_t *packet_create(int i, double d, long l, char *p) {
      struct packet_t *new = malloc(sizeof(struct packet_t));
      if (new) {
          new-&gt;i = i;
          new-&gt;d = d;
          new-&gt;l = l;
          new-&gt;p = p;
      }
      else {
          logError("failed to allocate memory");
      }
  
      return new;
  }
  
  int queue_destroy(struct queue_t *queue) {
      if (!queue) {
          logError("could not find queue!");
          return 0;
      }
      struct packet_t *p;
  
      for (int i = 0; i &lt; queue-&gt;size; i++) {
          p = *(queue-&gt;packets + i);
          packet_destroy(p);
      }
  
      //TODO test if not needed as it's already free'd in packet_destroy
      free(queue-&gt;packets);
      free(queue);
      return 0;
  }
  
  long test_queue(int val) {
      int sum = 0, finalTime = 0;
      clock_t startTime, finalTicks;
      startTime = clock();
  
      while (finalTime &lt; val) {
          struct queue_t *q = queue_create("test", 10);
          queue_destroy(
              sum++;
          finalTicks = (clock() - startTime);
          //        printf("ticks: %d\n", finalTicks);
          finalTime = (int)floor((finalTicks / (double)CLOCKS_PER_SEC));
          //        printf("time: %d\n", finalTime);
      }
  
      printf("Runtime: %d\n seconds", finalTime);
      printf("Added and removed %d queues\n", sum);
  }
  
  long test_packets(int val) {
      int finalTime = 0;
      struct queue_t *q = queue_create("test", 10);
      clock_t startTime, finalTicks;
      startTime = clock();
  
      while (finalTime &lt; val) {
          struct packet_t *t = packet_create(finalTime, finalTime + 1, finalTime + 2, NULL);
          queue_store(q, t);
          packet_destroy(queue_retrieve(q));
          finalTicks = (clock() - startTime);
          //        printf("ticks: %d\n", finalTicks);
          finalTime = (int)floor((finalTicks / (double)CLOCKS_PER_SEC));
          //        printf("time: %d\n", finalTime);
      }
  
      printf("Runtime: %d\n", finalTime);
      printf("Successfully added %li entries\n", q-&gt;total);
      printf("Failed to add %li entries\n", q-&gt;lost);
  
      queue_destroy(q);
  }
  
  void resetDecision() {
      decision = -1;
      isRunning = 1;
  }
  
  void checkDecision() {
      while (decision != 0 &amp;&amp; decision != 1 &amp;&amp; decision != 2) {
          printf("Select option:\n (1) Run queue test \n (2) Run packet test \n(0) to cancel \n");
          scanf("%d", &amp;decision);
      }
      if (decision == 0) {
          isRunning = 0;
      }
      else if (decision == 1) {
          int val = 0;
          while (val &lt;= 0) {
              printf("Enter the time to test");
              scanf("%d", &amp;val);
          }
          printf("Running test for %d seconds....\n", val);
          test_queue(val);
      }
      else if (decision == 2) {
          int val = 0;
          while (val &lt;= 0) {
              printf("Enter the time to test");
              scanf("%d", &amp;val);
          }
          printf("Running test for %d seconds....\n", val);
          test_packets(val);
      }
  
      if (decision != 0)
          resetDecision();
  }
  
  int main() {
      while (isRunning) {
          checkDecision();
      }
      return 0;
  }
  </code></pre>