<div dir="ltr">It's difficult to move this specific piece to the DIA implementation, and I think should probably stay here.  CoInitialize is supposed to be called by the application once per thread.  We can, of course, wrap this up inside the library with the use of some thread specific data, but the normal paradigm for doing programming with COM is to do this very early in main for the main thread.  It's usually the responsibility of the executable.  Because if you write it your library, what happens if someone else called it earlier with a different set of parameters?<div><br></div><div>It could be possible to write something like llvm::pdb::Initialize(); and llvm::pdb::Shutdown(); but this still has side effects outside of the library, and someone who wishes to use this library as part of a larger application would have confusing semantics.</div></div><br><div class="gmail_quote">On Tue Feb 10 2015 at 2:56:38 PM David Blaikie <<a href="mailto:dblaikie@gmail.com">dblaikie@gmail.com</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Tue, Feb 10, 2015 at 2:47 PM, Zachary Turner <span dir="ltr"><<a href="mailto:zturner@google.com" target="_blank">zturner@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: zturner<br>
Date: Tue Feb 10 16:47:14 2015<br>
New Revision: 228756<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=228756&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=228756&view=rev</a><br>
Log:<br>
Oops.  Don't call Windows functions on non-windows.<br>
<br>
Modified:<br>
    llvm/trunk/tools/llvm-pdbdump/llvm-pdbdump.cpp<br>
<br>
Modified: llvm/trunk/tools/llvm-pdbdump/llvm-pdbdump.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-pdbdump/llvm-pdbdump.cpp?rev=228756&r1=228755&r2=228756&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-pdbdump/llvm-pdbdump.cpp?rev=228756&r1=228755&r2=228756&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/tools/llvm-pdbdump/llvm-pdbdump.cpp (original)<br>
+++ llvm/trunk/tools/llvm-pdbdump/llvm-pdbdump.cpp Tue Feb 10 16:47:14 2015<br>
@@ -15,6 +15,7 @@<br>
<br>
 #include "llvm/ADT/ArrayRef.h"<br>
 #include "llvm/ADT/StringExtras.h"<br>
+#include "llvm/Config/config.h"<br>
 #include "llvm/DebugInfo/PDB/PDB.h"<br>
 #include "llvm/DebugInfo/PDB/IPDBEnumChildren.h"<br>
 #include "llvm/DebugInfo/PDB/IPDBSession.h"<br>
@@ -30,7 +31,9 @@<br>
 #include "llvm/Support/PrettyStackTrace.h"<br>
 #include "llvm/Support/Signals.h"<br>
<br>
+#if defined(HAVE_DIA_SDK)<br></blockquote></div></div></div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div><br>I'm assuming this logic will eventually be moved/built in to the DIA PDB library implementation?<br> </div></div></div></div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
 #include <Windows.h><br>
+#endif<br>
<br>
 using namespace llvm;<br>
<br>
@@ -88,11 +91,16 @@ int main(int argc_, const char *argv_[])<br>
<br>
   cl::ParseCommandLineOptions(argv.size(), argv.data(), "LLVM PDB Dumper\n");<br>
<br>
+#if defined(HAVE_DIA_SDK)<br>
   CoInitializeEx(nullptr, COINIT_MULTITHREADED);<br>
+#endif<br>
<br>
   std::for_each(opts::InputFilenames.begin(), opts::InputFilenames.end(),<br>
                 dumpInput);<br>
<br>
+#if defined(HAVE_DIA_SDK)<br>
   CoUninitialize();<br>
+#endif<br>
+<br>
   return 0;<br>
 }<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu" target="_blank">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</blockquote></div></div></div></blockquote></div>