Re: [PATCH] Add use of asprintf()

From: David Rowley <dgrowleyml(at)gmail(dot)com>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, Asif Naeem <anaeem(dot)it(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [PATCH] Add use of asprintf()
Date: 2013-10-15 05:55:58
Message-ID: CAApHDvqYf_cj3ymw7OWYRWdFs1BhYc_BDFLpHSkaP0rCQiPwCA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Oct 15, 2013 at 9:48 AM, Peter Eisentraut <peter_e(at)gmx(dot)net> wrote:

> On Mon, 2013-10-14 at 23:08 +1300, David Rowley wrote:
>
> >
> > Looks like something like:
> >
> >
> > #ifndef WIN32
> > #define HAVE_VA_COPY 1
> > #endif
> >
> >
> > would need to be added to asprintf.c, but also some work needs to be
> > done with mcxt.c as it uses va_copy unconditionally. Perhaps just
> > defining a macro for va_copy would be better for windows. I was not
> > quite sure the best header file for such a macro so I did not write a
> > patch to fix it.
>
> Does Windows not have va_copy? What do they use instead?
>
>
Not quite sure what is used instead as I've never had the need to use it
before, but Mircosoft do seem to be getting around to implementing the C99
standard for Visual Studios 2013. See here.

http://msdn.microsoft.com/en-us/library/vstudio/kb57fad8(v=vs.120).aspx

If we skip back to VS2012, it does not exist:

http://msdn.microsoft.com/en-us/library/vstudio/kb57fad8(v=vs.110).aspx

So maybe this is the fix for it, which I think should be forwards
compatible for vs2013 and beyond when we go there.

diff --git a/src/include/c.h b/src/include/c.h
index 8916310..30e68ff 100644
--- a/src/include/c.h
+++ b/src/include/c.h
@@ -63,6 +63,11 @@
#undef errcode
#endif

+/* Visual Studios 2012 and earlier don't have va_copy() */
+#if _MSC_VER <= 1700
+#define va_copy(dest, src) ((dest) = (src))
+#endif
+
/*
* We have to include stdlib.h here because it defines many of these macros
* on some platforms, and we only want our definitions used if stdlib.h
doesn't

Though this is not yet enough to get the windows build work with me... I'm
still getting link failures for isolationtester.c

"D:\Postgres\c\pgsql.sln" (default target) (1) ->
"D:\Postgres\c\isolationtester.vcxproj" (default target) (89) ->
(Link target) ->
isolationtester.obj : error LNK2019: unresolved external symbol
_pg_strdup referenced in function _try_complete_step
[D:\Postgres\c\isolationtester.vcxproj]
isolationtester.obj : error LNK2019: unresolved external symbol
_pg_asprintf referenced in function _try_complete_step
[D:\Postgres\c\isolationtester.vcxproj
]
.\Release\isolationtester\isolationtester.exe : fatal error LNK1120: 2
unresolved externals [D:\Postgres\c\isolationtester.vcxproj]

1 Warning(s)

I guess this is down to a make file error somewhere.

David

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message KONDO Mitsumasa 2013-10-15 06:11:22 Re: Compression of full-page-writes
Previous Message Asif Naeem 2013-10-15 05:53:09 Re: [PATCH] Add use of asprintf()