Re: BUG #15080: ecpg on windows doesn't define HAVE_LONG_LONG_INT

Tom Lane <tgl@sss.pgh.pa.us>

From: Tom Lane <tgl@sss.pgh.pa.us>
To: Huong Dangminh <huo-dangminh@ys.jp.nec.com>
Cc: Jonathan Allen <jallen@americansavingslife.com>, Michael Meskes <meskes@postgresql.org>, Andrew Gierth <andrew@tao11.riddles.org.uk>, "pgsql-bugs@lists.postgresql.org" <pgsql-bugs@lists.postgresql.org>, Akio Iwaasa <aki-iwaasa@vt.jp.nec.com>
Date: 2018-05-17T15:43:39Z
Lists: pgsql-bugs
Huong Dangminh <huo-dangminh@ys.jp.nec.com> writes:
> From: Tom Lane [mailto:tgl@sss.pgh.pa.us]
>> Well, we committed *something* about that:
>> https://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=fda3e65786763bd43abc576a23035a4cd24ed138
>> Does that not match the fix you were using?

> I confirmed that the above commit fix the case of not define HAVE_LONG_LONG_INT.

> But We found another case that causes "unsupported type "long long"" error in 
> Windows environment.
> In our case, We got the same error "unsupported type ...", because of the flag 
> HAVE_STRTOLL and HAVE_STRTOULL are not defined (*1).

Ah!  I looked through the uses of ECPG_UNSUPPORTED, and that seems to be
the only other thing that needs to be covered.

> I created a patch which defines the above two flags in Visual Studio 2013 or greater.
> # The two functions strtoll and strtoull are support from Visual Studio 2013
> Please confirm the attached.

It seems fairly unfortunate that this patch does not fix the problem
for as far back as MSVC has "long long" support.  From what I can tell,
we could use _strtoi64 and _strtoui64 on older Windows versions.  So
I'm imagining something like

#if (_MSC_VER > 1200)
#define HAVE_LONG_LONG_INT_64 1
#endif

...

#ifdef HAVE_LONG_LONG_INT_64
#define HAVE_STRTOLL 1
/* Before VS2013, use Microsoft's nonstandard equivalent function */
#if (_MSC_VER < 1800)
#define strtoll _strtoi64
#endif
#endif

and similarly for strtoull.

Please check that and see if it works.

BTW, is it possible to set up an ecpg test case to verify that this
stuff works?  It'd have to handle platforms without long long though,
so I'm not sure how to deal with that.

			regards, tom lane


Commits

  1. Remove configure's check for nonstandard "long long" printf modifiers.

  2. printf("%lf") is not portable, so omit the "l".

  3. Support platforms where strtoll/strtoull are spelled __strtoll/__strtoull.

  4. Arrange to supply declarations for strtoll/strtoull if needed.

  5. Hot-fix ecpg regression test for missing ecpg_config.h inclusion.

  6. Add some test coverage for ecpg's "long long" support.

  7. Recognize that MSVC can support strtoll() and strtoull().

  8. Fix up ecpg's configuration so it handles "long long int" in MSVC builds.