user32148: I would like to create a compile error so sketch does not upload in certain cases. 
I have written a library with a function that adds pins being used to an array. If the same pin is used twice I want to fail the compilation (preferably with an error that explains why). Is this possible?
void CheckPinNum(int newPinNum){
  for (int i=0; i <= PinArrayLength; i++){
    if (newPinNum == PinArray[i])
      failCompilation("You entered same pin twice!");
  }
}


user7508: To answer the question asked in the title:
#if some_condition
# error Some error message
#endif

But note that this technique only works at compile time, which
probably makes it useless for you.

32148: <p>I would like to create a compile error so sketch does not upload in certain cases. </p>

<p>I have written a library with a function that adds pins being used to an array. If the same pin is used twice I want to fail the compilation (preferably with an error that explains why). Is this possible?</p>

<pre><code>void CheckPinNum(int newPinNum){
  for (int i=0; i &lt;= PinArrayLength; i++){
    if (newPinNum == PinArray[i])
      failCompilation("You entered same pin twice!");
  }
}
</code></pre>
 7508: <p>To answer the question asked in the title:</p>

<pre class="lang-c++ prettyprint-override"><code>#if some_condition
# error Some error message
#endif
</code></pre>

<p>But note that this technique only works at <em>compile time</em>, which
probably makes it useless for you.</p>
