Re: [PATCH] Add use of asprintf()

Поиск
Список
Период
Сортировка
От David Rowley
Тема Re: [PATCH] Add use of asprintf()
Дата
Msg-id CAApHDvqYf_cj3ymw7OWYRWdFs1BhYc_BDFLpHSkaP0rCQiPwCA@mail.gmail.com
обсуждение исходный текст
Ответ на Re: [PATCH] Add use of asprintf()  (Peter Eisentraut <peter_e@gmx.net>)
Ответы Re: [PATCH] Add use of asprintf()  (Asif Naeem <anaeem.it@gmail.com>)
Список pgsql-hackers
On Tue, Oct 15, 2013 at 9:48 AM, Peter Eisentraut <peter_e@gmx.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.


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


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

 

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Asif Naeem
Дата:
Сообщение: Re: [PATCH] Add use of asprintf()
Следующее
От: KONDO Mitsumasa
Дата:
Сообщение: Re: Compression of full-page-writes