title: Writing a const and non-const variant of a function
body: <p>I implemented a rather complex functions, but for the sake of a minimal example, let's stick with this:</p>
  
  <pre><code>(const) char * my_function((const) char *input) {
    return input;
  }
  </code></pre>
  
  <p>The problem arises when I need to call the function one time with a const and once with a non-const value:</p>
  
  <pre><code>const char *a = "ABC";
  char b[3];
  
  // The following fails without using const in the declaration of my_function
  const char *result_a = my_function(a);
  
  // The following fails when using const in the declaration of my_function
  char *result_b = my_function(b);
  </code></pre>
  
  <p>Can this problem be solved in plain C without repeating the same function with different names?</p>
  
  <hr>
  
  <p>I know this can be done with a second file or an incredibly long <code>#define</code>, but is there an elegant solution?</p>