There are certain *rare* cases, it may be useful to prevent duplicate arguments to a macro.

Take this [`ELEM(value, ...)`](https://stackoverflow.com/a/24837037/432509) macro,

To check if `value` is either `A`, `B` or `C`.

```
if (ELEM(value, A, B, C)) { .... }

```

Someone could, by accident passes in the same argument multiple times, eg:

```
if (ELEM(value, A, B, B)) { .... }

```

While valid C, but almost certainly an accident, and **highly unlikely** to be what the developer intended.

*... this is of course a trivial example, actual error cases would be more complicated.*

Question
--------

**Is there a way to have the compiler warn/error  
when passing in duplicate arguments?**

---

Clarification:

* Arguments are not *necessarily*, **all** constants (they could be mixed with variables too).

---

Notes...

* Asking because this is an actual bug I found in some code recently.  
While theres a limit macros/compilers can go to prevent mistakes, this could have been detected early if the macro didn't allow it.  
*Of course these kinds of mistakes should be found in code review...  
nevertheless, mistakes happen.*
* This may have to use some GCC/compiler specific extensions, such as `__builtin_constant_p`.
* One way to do this *(which isn't fool proof but would help avoid **some** mistakes)*,
could be to convert the identifiers to strings, then static-assert if any of the identifiers are exact matches.  
Having the obvious drawback that different identifiers may represent the same constant value. The the same identifier could also be written so as to not compare, eg: `A[0]` vs `A[ 0 ]`.
* If the preprocessor/compiler can't do this easily, a fall-back solution may be to do some basic static checking tool.