Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ISO C90 forbids variable length array ‘arr’ [-Werror=vla] #17

Open
joelonsql opened this issue Apr 26, 2021 · 10 comments
Open

ISO C90 forbids variable length array ‘arr’ [-Werror=vla] #17

joelonsql opened this issue Apr 26, 2021 · 10 comments

Comments

@joelonsql
Copy link

Build fails on Ubuntu 20.04.2 LTS running Ubuntu 13.2-1.pgdg20.04+1:

polygon.c: In function ‘spherepoly_in’:
polygon.c:827:3: error: ISO C90 forbids variable length array ‘arr’ [-Werror=vla]
  827 |   SPoint  arr[nelem];
      |   ^~~~~~
polygon.c: In function ‘spherepoly_area’:
polygon.c:895:2: error: ISO C90 forbids variable length array ‘s’ [-Werror=vla]
  895 |  SPoint  s[poly->npts + 2];
      |  ^~~~~~
cc1: some warnings being treated as errors
make: *** [<builtin>: polygon.o] Error 1
@esabol
Copy link

esabol commented Apr 27, 2021

I’m not affiliated with the pgsphere team. I just happen to watch this repo.

Anyway, I just wanted to suggest that you try adding -std=c99 to the compilation command for this file or use /usr/bin/c99 instead of gcc.

By the way, there’s also a pgsphere/pgsphere repo. I’m not sure which repo is the best one to open issues with these days, but that repo has shown some activity recently.

@joelonsql
Copy link
Author

I’m not affiliated with the pgsphere team. I just happen to watch this repo.

Anyway, I just wanted to suggest that you try adding -std=c99 to the compilation command for this file or use /usr/bin/c99 instead of gcc.

By the way, there’s also a pgsphere/pgsphere repo. I’m not sure which repo is the best one to open issues with these days, but that repo has shown some activity recently.

Thanks for helping out. I'll try the pgsphere/pgsphere repo instead.

@carlosadean
Copy link

@joelonsql did the @esabol 's suggestion work?
How did you use it?

I'm trying to upgrade from 9.2 to 13.4 and I'm getting the same error.

thanks

@esabol
Copy link

esabol commented Sep 22, 2021

What have you tried exactly, @carlosadean ?

Are you asking how to add the -std=c99 flag to the compilation command?

@carlosadean
Copy link

@esabol how shoud I use this flag in the compilation command?

@esabol
Copy link

esabol commented Sep 23, 2021

Try this:

make CC="gcc -std=c99"

If that doesn't work, replace c99 with gnu99. Please report back here whether either of those help.

@carlosadean
Copy link

carlosadean commented Sep 29, 2021

@esabol unfortunately the command and its parameters didn't work and the result is always the same for both.

make[1]: Entering directory `/data/PostgreSQL/13.4/src/postgresql-13.4/src/backend'
make -C catalog distprep generated-header-symlinks
make[2]: Entering directory `/data/PostgreSQL/13.4/src/postgresql-13.4/src/backend/catalog'
make[2]: Nothing to be done for `distprep'.
make[2]: Nothing to be done for `generated-header-symlinks'.
make[2]: Leaving directory `/data/PostgreSQL/13.4/src/postgresql-13.4/src/backend/catalog'
make -C utils distprep generated-header-symlinks
make[2]: Entering directory `/data/PostgreSQL/13.4/src/postgresql-13.4/src/backend/utils'
make[2]: Nothing to be done for `distprep'.
make[2]: Nothing to be done for `generated-header-symlinks'.
make[2]: Leaving directory `/data/PostgreSQL/13.4/src/postgresql-13.4/src/backend/utils'
make[1]: Leaving directory `/data/PostgreSQL/13.4/src/postgresql-13.4/src/backend'
gcc -std=c99 -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -O2 -fPIC -I. -I. -I/data/PostgreSQL/13.4/src/postgresql-13.4/src/include  -D_GNU_SOURCE   -c -o sscan.o sscan.c
gcc -std=c99 -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -O2 -fPIC -I. -I. -I/data/PostgreSQL/13.4/src/postgresql-13.4/src/include  -D_GNU_SOURCE   -c -o sparse.o sparse.c
gcc -std=c99 -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -O2 -fPIC -I. -I. -I/data/PostgreSQL/13.4/src/postgresql-13.4/src/include  -D_GNU_SOURCE   -c -o sbuffer.o sbuffer.c
gcc -std=c99 -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -O2 -fPIC -I. -I. -I/data/PostgreSQL/13.4/src/postgresql-13.4/src/include  -D_GNU_SOURCE   -c -o vector3d.o vector3d.c
gcc -std=c99 -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -O2 -fPIC -I. -I. -I/data/PostgreSQL/13.4/src/postgresql-13.4/src/include  -D_GNU_SOURCE   -c -o point.o point.c
gcc -std=c99 -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -O2 -fPIC -I. -I. -I/data/PostgreSQL/13.4/src/postgresql-13.4/src/include  -D_GNU_SOURCE   -c -o euler.o euler.c
gcc -std=c99 -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -O2 -fPIC -I. -I. -I/data/PostgreSQL/13.4/src/postgresql-13.4/src/include  -D_GNU_SOURCE   -c -o circle.o circle.c
gcc -std=c99 -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -O2 -fPIC -I. -I. -I/data/PostgreSQL/13.4/src/postgresql-13.4/src/include  -D_GNU_SOURCE   -c -o line.o line.c
gcc -std=c99 -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -O2 -fPIC -I. -I. -I/data/PostgreSQL/13.4/src/postgresql-13.4/src/include  -D_GNU_SOURCE   -c -o ellipse.o ellipse.c
gcc -std=c99 -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -O2 -fPIC -I. -I. -I/data/PostgreSQL/13.4/src/postgresql-13.4/src/include  -D_GNU_SOURCE   -c -o polygon.o polygon.c
polygon.c: In function ‘spherepoly_in’:
polygon.c:827:3: error: variable length array ‘arr’ is used [-Werror=vla]
   SPoint  arr[nelem];
   ^
polygon.c: In function ‘spherepoly_area’:
polygon.c:895:2: error: variable length array ‘s’ is used [-Werror=vla]
  SPoint  s[poly->npts + 2];
  ^
cc1: some warnings being treated as errors
make: *** [polygon.o] Error 1

@esabol
Copy link

esabol commented Oct 1, 2021

I just noticed that the directory in which you are compiling polygon.c is /data/PostgreSQL/13.4/src/postgresql-13.4/src/backend. That looks like you put the pgsphere source code in the same directory as the source code for PostgreSQL. If that's the case, then that's wrong, I think. I put the pgsphere directory in my PostgreSQL contrib directory, like this: /path/to/src/postgresql-x.y/contrib/pgsphere-a.b.c/.

Compiling the source code in the correct location still won't solve the compilation error you are seeing, I think. Two possible solutions:

  1. You need to remove -Werror=vla from the compilation command. Try executing either of the following commands:
gcc -std=gnu99 -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -O2 -fPIC -I. -I. -I/data/PostgreSQL/13.4/src/postgresql-13.4/src/include  -D_GNU_SOURCE   -c -o polygon.o polygon.c && make

Or maybe this:

make CC="gcc -std=gnu99" CFLAGS="-Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -O2 -fPIC -I. -I. -I/data/PostgreSQL/13.4/src/postgresql-13.4/src/include  -D_GNU_SOURCE"
  1. There's a pull request to change the source code to get this to compile with -Werror=vla, and you can find the patch here:

https://github.com/akorotkov/pgsphere/pull/14/files

Hope this helps!

@SFotopoulou
Copy link

Hi,

not sure if this is useful but we have made a docker container for postgres 14, using the fix from https://github.com/mdgomes/pgsphere. It also includes the pg_healpix extension.

You will find instructions here.

Cheers,
Sotiria

@molinaro-m
Copy link

Hi,

some further information, that might be useful.

pgSphere is maintained at postgrespro repo.

It should work on PostgreSQL 10+ directly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants