<div dir="ltr">The reason is that we want to keep the C API stable. Sorting the C++ enums alphabetically or logically shouldn't impact the C API.</div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Jul 17, 2015 at 1:33 AM, Tim Besard <span dir="ltr"><<a href="mailto:tim.besard@elis.ugent.be" target="_blank">tim.besard@elis.ugent.be</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi all,<br>
<br>
I was looking at the C API (adding some missing Build* methods) and was<br>
wondering about how to move between C++ and C enums. There seem to be multiple<br>
ways of doing this:<br>
* dedicated method: eg LLVMAtomicOrdering->AtomicOrdering in mapFromLLVMOrdering<br>
* local switch statement: eg. LLVMAtomicRMWBinOp->AtomicRMWInst in<br>
  LLVMBuildAtomicRMW<br>
* static cast: eg. LLVMVisibility->GlobalValue::VisibilityTypes in<br>
  LLVMSetVisibility<br>
<br>
Are there specific reasons for these different approaches? At first sight, it<br>
seems like the C enums can be one-on-one mapped to their C++ counterpart, so a<br>
static_cast should suffice. Sanity checking the input enum doesn't seem like a<br>
reason either, because only some of the manual conversion fragments end with<br>
a fatal error.<br>
<br>
What is the preferred way of doing this? Does it make sense to convert the other<br>
approaches?<br>
<br>
Best,<br>
Tim<br>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a>         <a href="http://llvm.cs.uiuc.edu" rel="noreferrer" target="_blank">http://llvm.cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" rel="noreferrer" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
</blockquote></div><br></div>