title: Pointers and static variables in C
body: <p>I'm having some problems with pointers in a school task, since I haven't programmed in C in a long time. I'm trying to store a value called rssi on a device running Contiki-NG which is like an OS for IOT devices.</p>
  <p>I initialized the variable rssi in the beginning of the code:</p>
  <pre><code>static int8_t *rssi;
  </code></pre>
  <p>Then, in a function called on_reception, I'm updating the variable:</p>
  <pre><code>void on_reception(const void *data,
      uint16_t len,
      const linkaddr_t *src,
      const linkaddr_t *dest)
  {
     ....
     // Update variable
     rssi = &amp;packetbuf_attr(PACKETBUF_ATTR_RSSI);
  }
  </code></pre>
  <p>And then in the main loop I'm trying to store this value using a provided cfs_write function:</p>
  <pre><code>PROCESS_THREAD(receiver_process, ev, data)
  {
     PROCESS_BEGIN();
     ....
  
     while(1) {
      PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&amp;periodic_timer));
      etimer_reset(&amp;periodic_timer);
      entry = akes_nbr_head();
      if(entry &amp;&amp; entry-&gt;permanent) {
        akes_trickle_stop();
        break;
      }
      
      // Store rssi value
      r = cfs_write(fd, &amp;rssi, sizeof(rssi));
    }
  }
  </code></pre>
  <p>However I'm getting problems like:</p>
  <p>&quot;lvalue required as unary '&amp;' operand&quot;</p>
  <p>I've tried using '*' instead of '&amp;' and what not but I can't seem to get it to work. Could anyone point me in the right direction?</p>
  <p>EDIT:
  PACKETBUF_ATTR is a struct that contains a value according to the header file:</p>
  <pre><code>typedef uint16_t packetbuf_attr_t;
  
  struct packetbuf_attr {
    packetbuf_attr_t val;
  };
  </code></pre>
  <p>They gave me an example of printing the values:</p>
  <pre><code>  memcpy(&amp;counter, data, sizeof(counter));
    printf(&quot;B,PING,%lu,%u,%lu,%i,0\n&quot;,
        clock_time(),
        (uint8_t)packetbuf_attr(PACKETBUF_ATTR_CHANNEL),
        counter,
        (int8_t)packetbuf_attr(PACKETBUF_ATTR_RSSI));
  </code></pre>