title: Ignore Ada Function Return Values
body: <p>Is there a way to ignore return values in <code>Ada</code> functions?</p>
  
  <p>I have a function which imports from an Intrinsic.</p>
  
  <pre><code>subtype int32 is Interfaces.Interger_32;
  
  function Intrinsic_Sync_Add_And_Fetch
      (P : access int32; I : int32) return int32;
  
  pragma Import(
              Intrinsic, 
              Intrinsic_Sync_Add_And_Fetch, 
              "__sync_add_and_fetch_4");
  </code></pre>
  
  <p>If I want to use this in a procedure, I need to accept the return value or I will get a compiler error:</p>
  
  <pre><code>cannot use function Intrinsic_Sync_Add_And_Fetch in procedure call.
  </code></pre>
  
  <p>But, if I create a variable that simply takes the return value of the function and is never used then I get compiler warnings. Obviously, I'd rather avoid those.</p>
  
  <p>I can't very well assign the value <em>back</em> to the value I'm adding to; this would undermine the point of the <code>add</code> operation being atomic.</p>
  
  <p>There is the option of taking the value and doing <em>something</em> with it, like:</p>
  
  <pre><code>val := Intrinsic_Sync_Add_And_Fetch(...);
  if val := 0 then null; end if;
  </code></pre>
  
  <p>It forces the code to compile without errors or warnings, but it seems stupid to me. How can I "get around" this language feature and safely ignore the return value?</p>
  
  <p><strong>Edit: What is __sync_add_and_fetch_4?</strong></p>
  
  <p>This is a built-in atomic operation available on Intel CPUs. As such, part of my <code>Autoconf</code>/<code>Automake</code> process would be deciding if the operation is available, and use a fallback implementation, which involves a critical section, if it's not.</p>
  
  <p>You can read about this and similar operations in <a href="http://gcc.gnu.org/onlinedocs/gcc-4.1.0/gcc/Atomic-Builtins.html#Atomic-Builtins" rel="nofollow">GCC's section on atomic builtins</a>.</p>
  
  <p>The <code>__sync_add_and_fetch_4</code> does pretty much exactly what it says. In <code>C</code>, it would look something like this: </p>
  
  <pre><code>int32_t __sync_add_and_fetch_4(int32_t *ptr, int32_t value) {
      *ptr += value;
      return *ptr;
  }
  </code></pre>
  
  <p>So it's an atomic addition operation, which returns the result of the addition. Basically, it's an atomic <code>+=</code> operator.  The <code>_4</code> means that it takes a 4-byte integer.</p>
  
  <p><em><strong>Edit</em></strong>: I understand that I could probably just switch off that particular compiler warning, but that always feels dirty to me. If there's a solution available that allows me to continue using <code>-Wall -Werror</code> then I'd love to see it.</p>