<div dir="ltr">looks good, can you add a comment to explain why it's inlined though.</div><br><div class="gmail_quote"><div dir="ltr">On Thu, Aug 20, 2015 at 12:14 PM Chaoren Lin <<a href="mailto:chaorenl@google.com">chaorenl@google.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">chaoren created this revision.<br>
chaoren added a reviewer: zturner.<br>
chaoren added a subscriber: lldb-commits.<br>
<br>
dllexport doesn't work if linking against a static library with its own<br>
copy of snprintf.<br>
<br>
<a href="http://reviews.llvm.org/D12206" rel="noreferrer" target="_blank">http://reviews.llvm.org/D12206</a><br>
<br>
Files:<br>
include/lldb/Host/windows/win32.h<br>
source/Host/windows/Windows.cpp<br>
<br>
Index: source/Host/windows/Windows.cpp<br>
===================================================================<br>
--- source/Host/windows/Windows.cpp<br>
+++ source/Host/windows/Windows.cpp<br>
@@ -203,18 +203,17 @@<br>
}<br>
<br>
#if _MSC_VER < 1900<br>
-int snprintf(char *buffer, size_t count, const char *format, ...)<br>
+namespace lldb_private {<br>
+int vsnprintf(char *buffer, size_t count, const char *format, va_list argptr)<br>
{<br>
int old_errno = errno;<br>
- va_list argptr;<br>
- va_start(argptr, format);<br>
- int r = vsnprintf(buffer, count, format, argptr);<br>
+ int r = ::vsnprintf(buffer, count, format, argptr);<br>
int new_errno = errno;<br>
buffer[count-1] = '\0';<br>
if (r == -1 || r == count)<br>
{<br>
FILE *nul = fopen("nul", "w");<br>
- int bytes_written = vfprintf(nul, format, argptr);<br>
+ int bytes_written = ::vfprintf(nul, format, argptr);<br>
fclose(nul);<br>
if (bytes_written < count)<br>
errno = new_errno;<br>
@@ -224,9 +223,9 @@<br>
r = bytes_written;<br>
}<br>
}<br>
- va_end(argptr);<br>
return r;<br>
}<br>
+} // namespace lldb_private<br>
#endif<br>
<br>
#endif // _MSC_VER<br>
Index: include/lldb/Host/windows/win32.h<br>
===================================================================<br>
--- include/lldb/Host/windows/win32.h<br>
+++ include/lldb/Host/windows/win32.h<br>
@@ -65,8 +65,18 @@<br>
int strncasecmp(const char* s1, const char* s2, size_t n);<br>
<br>
#if _MSC_VER < 1900<br>
-int __declspec(dllexport)<br>
-snprintf(char *buffer, size_t count, const char *format, ...);<br>
+namespace lldb_private {<br>
+int vsnprintf(char *buffer, size_t count, const char *format, va_list argptr);<br>
+}<br>
+<br>
+int inline snprintf(char *buffer, size_t count, const char *format, ...)<br>
+{<br>
+ va_list argptr;<br>
+ va_start(argptr, format);<br>
+ int r = lldb_private::vsnprintf(buffer, count, format, argptr);<br>
+ va_end(argptr);<br>
+ return r;<br>
+}<br>
#endif<br>
<br>
#define STDIN_FILENO 0<br>
<br>
<br>
</blockquote></div>