title: Storing a pointer to a callback with arguments function in c
body: <p>I am trying to store a reference (I think that's what it is) to a call back for local use later on. The code I have tried is shown below. </p>
  
  <pre><code>void (Port4Task)(uint8_t);   // user function
  void BumpInt_Init(void(*task)(uint8_t)){
    Port4Task = task();
  </code></pre>
  
  <p>Unfortunately when I try this I get an error "expression must be a modifiable lvalue" and "too few arguments in function call". I have also tried, </p>
  
  <pre><code>uint8_t value;
  void (Port4Task)(uint8_t);   // user function
  void BumpInt_Init(void(*task)(uint8_t)){
    Port4Task = task(value);
  </code></pre>
  
  <p>But I still get the error "expression must be a modifiable lvalue". If there are any suggestions, explanations or clarifications as to what I should be doing, what I'm doing wrong or how I could be doing things better I would really appreciate hearing from the community.</p>
  
  <p>Thanks
  Kas</p>
  
  <p>I have also tried</p>
  
  <pre><code>void (Port4Task)();   // user function
  void BumpInt_Init(void(*task)(uint8_t)){
  Port4Task = task;
  </code></pre>
  
  <p>And</p>
  
  <pre><code>void (Port4Task)(uint8_t);   // user function
  void BumpInt_Init(void(*task)(uint8_t)){
  Port4Task = task;
  </code></pre>
  
  <p>Using this I still get the lvalue error mentioned above. This was in fact my first attempt.</p>