pganalyze / libpg_query

C library for accessing the PostgreSQL parser outside of the server environment
BSD 3-Clause "New" or "Revised" License
1.21k stars 182 forks source link

Error with CLOCK_REALTIME #234

Open Raksha2606 opened 10 months ago

Raksha2606 commented 10 months ago

Trying to compile in linux 3.10.0-1160.el7.x86_64 with -std=gnu99. But getting below error related to time.h ./src/postgres/include/portability/instr_time.h:118:2: warning: implicit declaration of function ‘clock_gettime’ [-Wimplicit-function-declaration] clock_gettime(PG_INSTR_CLOCK, &tmp); ^ ./src/postgres/include/portability/instr_time.h:108:24: error: ‘CLOCK_REALTIME’ undeclared (first use in this function)

define PG_INSTR_CLOCK CLOCK_REALTIME

                    ^

./src/postgres/include/portability/instr_time.h:118:16: note: in expansion of macro ‘PG_INSTR_CLOCK’ clock_gettime(PG_INSTR_CLOCK, &tmp); ^ ./src/postgres/include/portability/instr_time.h:108:24: note: each undeclared identifier is reported only once for each function it appears in

define PG_INSTR_CLOCK CLOCK_REALTIME

                    ^

./src/postgres/include/portability/instr_time.h:118:16: note: in expansion of macro ‘PG_INSTR_CLOCK’ clock_gettime(PG_INSTR_CLOCK, &tmp);

Tried all possible solutions mentioned online like: adding

define _GNU_SOURCE

define _POSIX_C_SOURCE = 199309L / #define _POSIX_C_SOURCE >= 199309L

Also tried adding before time.h But nothing worked.

Any help would be appreciated.

lfittl commented 10 months ago

Thanks for the report!

Could you confirm which commands you're running exactly? (make in the project root?)

Additionally, which distribution are you using? (looks like RHEL7 or CentOS7?)

Raksha2606 commented 10 months ago

Thanks for the report!

Could you confirm which commands you're running exactly? (make in the project root?)

Additionally, which distribution are you using? (looks like RHEL7 or CentOS7?)

Hi, Yes distribution is CentOS version 7 , and the only change I have made before running make in project root is adding -std=gnu99 because of some c99 for loop related error.