Re: psql tab-complete
От | Thomas Munro |
---|---|
Тема | Re: psql tab-complete |
Дата | |
Msg-id | CA+hUKGKLm8fdP_H3CtwgeMbe_6vqrKC20b+EtzTsmZOOVztCfg@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: psql tab-complete (Michael Paquier <michael@paquier.xyz>) |
Ответы |
Re: psql tab-complete
|
Список | pgsql-hackers |
On Sat, Oct 26, 2019 at 4:59 PM Michael Paquier <michael@paquier.xyz> wrote: > On Fri, Oct 25, 2019 at 11:57:18AM +0300, Victor Spirin wrote: > > This patch resolved one problem in the tab-complete.c on MSVC. The > > VA_ARGS_NARGS macros now work correctly on Windows. > > Can you explain why and in what the use of EXPAND() helps with MSVC > builds? Any references which help to understand why this is better? > If this change is needed, this also surely needs a comment to explain > the difference. Since I really want to be able to use VA_ARGS_NARGS() elsewhere, I looked into this. There are various derivatives of that macro, some using GCC/Clang-only syntax and that work on GCC and MSVC, splattered all over the internet, but the original, coming as it does from a C standards newsgroup[1], does not. There are also lots of complaints that the original standard version doesn't work on MSVC, with analysis: https://stackoverflow.com/questions/5134523/msvc-doesnt-expand-va-args-correctly https://stackoverflow.com/questions/32399191/va-args-expansion-using-msvc https://learn.microsoft.com/en-us/cpp/build/reference/zc-preprocessor?view=msvc-170 The short version is that __VA_ARGS__ is not tokenized the way the standard requires (it's considered to be a single token unless you shove it back through the preprocessor again, which is what EXPAND() does), but you can fix that with /Zc:preprocessor. That switch only works in Visual Studio 2019 and up, and maybe also 2017 if you spell it /experimental:preprocessor. We still claim to support older compilers. Assuming those switches actually work as claimed, I see two choices: commit this hack with a comment reminding us to clean it up later, or drop 2015. [1] https://groups.google.com/g/comp.std.c/c/d-6Mj5Lko_s
В списке pgsql-hackers по дате отправления: