0

I have installed pycparser that parses C code.

Using pycparser I want to parse an open source project, namely PostgreSQL(version-11.0). I have build it using Visual Studio Express 2017 compiler suite. However, during compilation it cannot find some header files, namely windows.h and winsock2.h.

While looking at the directory structure of the build PostgreSQL, I find that it does not have these header files. How to fix this issue?

Also a strange error occurred as:

postgresql/src/include/c.h:363:2: error: #error must have a working 64-bit integer datatype

Note: I am using Windows 10 64-bit platform and postgresql-11.0

The steps are as follows:
I downloaded visual studio 2017, Windows-10 SDK, Active Perl as described in the steps to build from source in PostgreSQL.

After this I open the developer command prompt of Visual Studio and navigate to the folder postgresql-11.0/src/tools/msvc

Use command "build" to build postgresql. The build process was successful, but still windows.h and winsock2.h was not found in directory structure of PostgreSQL.

Laurenz Albe
  • 209,280
  • 17
  • 206
  • 263
  • Please describe the exact steps you used to build PostgreSQL. `windows.h` and `winsock2.h` should be provided by MSVC. The MSVC build process should copy `pg_config.h.win32` to `pg_config.h` so that `HAVE_LONG_LONG_INT_64` is defined. You must be missing that step, else you shouldn't get that error message. – Laurenz Albe Oct 25 '18 at 22:41
  • I have edited my question and mentioned steps followed by me to build postgresql – Aditi Gupta Oct 26 '18 at 08:53
  • I have seen both files i.e., pg_config.h.win32 and pg_config.h. Both files are exact replica of each other. Still i am getting this error message. – Aditi Gupta Oct 27 '18 at 11:34
  • As I said in my answer, you'll have to teach this pycparser to find them. Note that only GNU make is supported with PostgreSQL, so you are on your own here. – Laurenz Albe Oct 27 '18 at 11:42
  • Sir, i have been successfully able to teach pycparser to find these files i.e., windows.h and winsock2.h. The error that still persists is:: postgresql/src/include/c.h:363:2: error: #error must have a working 64-bit integer datatype – Aditi Gupta Oct 28 '18 at 17:17
  • I have added more to the answer. No need to call me sir, as I am not of noble extraction. – Laurenz Albe Oct 29 '18 at 07:41

1 Answers1

0

I don't know pycparser, but your problem probably has two aspects to it:

  1. You didn't give pycparser the correct list of include directories. The header files you mention are not part of PostgreSQL.

    Maybe you can get the list from the environment of the Visual Studio prompt. I don't have a Windows here to verify that.

  2. The error message means that neither HAVE_LONG_INT_64 nor HAVE_LONG_LONG_INT_64 are defined.

    Now pg_config.h.win32, which is copied to pg_config.h during the MSVC install process, has the following:

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

    Since you are not using MSVC, you probable don't have _MSC_VER set, which causes the error.

    You could define _MSC_VER and see if you get to build then.

Essentially you are in a tight spot here, because pycparser is not a supported build procedure, so you'll have to dig into the source and fix things as you go. Without an understanding of the PostgreSQL source and the build process, you probably won't get far.

Laurenz Albe
  • 209,280
  • 17
  • 206
  • 263