I am wanting to build gnucobol from the AUR on Archlinux, but I get the following error when not using a CFLAG "-std=gnu17":
call.c:Infunction‘cob_call’:call.c:1352:14:error:toomanyargumentstofunction‘unifunc.funcint’;expected0,have1881352|i=unifunc.funcint(pargv[0],pargv[1],pargv[2],pargv[3]|^~~~~~~~~~~~~~~Infileincludedfromcoblocal.h:52,fromcall.c:51:common.h:1179:27:note:declaredhere1179|int(*funcint)();/* Function returning "int" */|^~~~~~~make[2]:***[Makefile:614:call.lo]Error1
I would have liked to provide a patch, but I am afraid that that is a bit above my head. Could anyone please assist?
Some more context:
* gcc version 15.1.1 20250425 (GCC)
* build.log
* config.log
* trying to build GNUCobol 3.2 via AUR
Thank you very much!
Last edit: Edmund Lodewijks 2025-05-03
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I'd need to do more testing, but you could either go down to -std=gnu99 or change all its use to cast to the correct type (that would also apply to codegen), possibly after changing libcob/common.h to
typedefunion__cob_call_union{void*(*funcptr)(void*);/* Function returning "void *" */void(*funcnull)(void*);/* Function returning nothing */cob_field*(*funcfld)(void*);/* Function returning "cob_field *" */int(*funcint)(void*);/* Function returning "int" */void*funcvoid;/* Redefine to "void *" */#ifdef _WIN32 /* stdcall variants */void*(__stdcall*funcptr_std)(void*);void(__stdcall*funcnull_std)(void*);cob_field*(__stdcall*funcfld_std)(void*);int(__stdcall*funcint_std)(void*);#endif}cob_call_union;
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
# Until fixed, the following CFLAGs are added:
- CFLAGS="$CFLAGS -Wno-error=implicit-function-declaration -Wno-error=incompatible-pointer-types -std=gnu17" ./configure \+ ./configure CC="gcc -std=gnu17" CFLAGS="$CFLAGS -Wno-error=implicit-function-declaration -Wno-error=incompatible-pointer-types" \ --prefix=/usr \
--infodir=/usr/share/info \
--enable-static=no \
--with-db \
--with-json=json-c
You possibly also get around of not setting CFLAGS (I don't know) - ensure a working compiler by running make check during the build - I guess that's automatically done.
Last edit: Simon Sobisch 2025-05-03
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Please note that I am not a (C) programmer! Please check carefully over the below code sample and logic of it!
If I understand correctly, adding "void * " causes C to expect 1 argument. However, in the given case, many arguments are passed to the function. Therefore, I tried the following:
int (*funcint)(void *, ...); /* Function returning "int" */
This, however, caused an issue in another section, when it tried to pass zero arguments, and now the function was expecting at least 1 argument.
I got it working by simply using the following, but I am not sure that this is correct.
int (*funcint)(...); /* Function returning "int" */
I will look into the other suggestions you sent while I was typing this message. Thank you very much for your swift help!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
add CFLAGS="-Wincompatible-pointer-types" to your configure line (as that is a "precious" var, pass it to configure, not exporting it
use one of --enable-hardening (will keep fortification and enable -O, possibly add more hardening options) of --disable-hardening (background: your build environment defines the fortification and likely -O by default, but we drop the -O normally for COBOL modules if you don't use cobc -O)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thank you for the explanations!
* I learned a bit about "precious" variables, and will amend some other PKGBUILDs I maintain.
* I was surprised that the standard hardening options from my system were not applied, despite their being set on the ./configure line. Now I understand that some are dropped automatically, and --enable-hardening must be set.
My current PKGBUILD for gnucobol contains the following for ./configure:
The original one is "zero to unlimited arguments" until C23 where it is identical to (void) - exactly zero arguments.
anything with ... is a variadic argument list - those are placed differently on the stack and won't work with functions that have for example 4 parameters.
The goal here is to increase type safety if no explicit casts are done. I'll possibly inspect the optional use of libffi in a bunch of days, but I guess that this may only work correctly (for COBOL where you may omit trailing OPTIONAL arguments) if the previously loaded caller provides metadata about the amount of arguments - and those are used... which is actually a good idea for 4.x, so maybe I inspect libffi "more later"...
What I may do earlier is replacing the union by a simple void *func (void) and then always cast... but I may have tried that before running into compiler warnings (clang?) about "bad practice, may break at runtime".
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I will revert the ... and await any further info from you. In the meantime, I can also simply add the CC="gcc -std=gnu17" line. Is GnuCOBOL v3 still developed, or is development supposed to only go into v4, meaning that you would rather spend your time on v4?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
We (@ddeclerck does the work and necessary adjustments, I'm doing the review) are in the process of merging 3.x to 4.x. In any case there will be a 3.3 release this year (maybe in 2 months) and I'm indeed mostly working on the 3.x branch. It is not clear yet if 3.3 will be the last release of the 3.x version, but focus will go to 4 as well as V-ISAM after its release.
Note: 3.2 had translation updates, you possibly want to update French, German and Serbian manually. Side note: I'll drop any translation from the distribution that doesn't have more than 50% translated before the 3.3 release, so Spanish, Turkish and Swedish may or may not stay in (depending on translators which I'll send a friendly ping after the first 3.3rc).
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi all!
I am wanting to build gnucobol from the AUR on Archlinux, but I get the following error when not using a CFLAG "-std=gnu17":
I would have liked to provide a patch, but I am afraid that that is a bit above my head. Could anyone please assist?
Some more context:
* gcc version 15.1.1 20250425 (GCC)
* build.log
* config.log
* trying to build GNUCobol 3.2 via AUR
Thank you very much!
Last edit: Edmund Lodewijks 2025-05-03
I'd need to do more testing, but you could either go down to
-std=gnu99
or change all its use to cast to the correct type (that would also apply to codegen), possibly after changing libcob/common.h toHm, reading the port notes at https://www.gnu.org/software/gcc//gcc-15/porting_to.html#c23-fn-decls-without-parameters seems to say that this does not happen with
-std=gnu17
and testing their example on godbolt has indeed that error when compiled without -std (which means-std=gnu23
since GCC15 and meant-std=gnu17
in older versions)...And checking config.log shows that there is no std set. Your adjustment to the arch package is also not correct per autotools documentation.
I suggest to change https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=gnucobol as follows:
You possibly also get around of not setting CFLAGS (I don't know) - ensure a working compiler by running
make check
during the build - I guess that's automatically done.Last edit: Simon Sobisch 2025-05-03
Oh, and if you update the AUR package, you likely also want to include two important patches - see https://git.adelielinux.org/adelie/packages/-/commit/21fe3ef399c25f030d6657e83cc635335f3a9f40#435d163c05dbd4ff7d8a89cc0187a770d86666b7
Please note that I am not a (C) programmer! Please check carefully over the below code sample and logic of it!
If I understand correctly, adding "void * " causes C to expect 1 argument. However, in the given case, many arguments are passed to the function. Therefore, I tried the following:
This, however, caused an issue in another section, when it tried to pass zero arguments, and now the function was expecting at least 1 argument.
I got it working by simply using the following, but I am not sure that this is correct.
I will look into the other suggestions you sent while I was typing this message. Thank you very much for your swift help!
Just an update as to what I have done in the mean time, awaiting your feedback on the above.
-std=gnu17
to outsideCFLAGS
(thanks!)make check
andmake test
suite. There are a LOT of errors on my build. I suppose many are due to warnings. See an example below:Last edit: Edmund Lodewijks 2025-05-03
You definitely want to:
CFLAGS="-Wincompatible-pointer-types"
to your configure line (as that is a "precious" var, pass it to configure, not exporting it--enable-hardening
(will keep fortification and enable -O, possibly add more hardening options) of--disable-hardening
(background: your build environment defines the fortification and likely -O by default, but we drop the -O normally for COBOL modules if you don't usecobc -O
)Thank you for the explanations!
* I learned a bit about "precious" variables, and will amend some other
PKGBUILDs
I maintain.* I was surprised that the standard hardening options from my system were not applied, despite their being set on the ./configure line. Now I understand that some are dropped automatically, and
--enable-hardening
must be set.My current PKGBUILD for gnucobol contains the following for ./configure:
The "std=gnu23" is currently only there so that I can quickly change to gnu17 for testing. Ideally it will be removed in the end.
The original one is "zero to unlimited arguments" until C23 where it is identical to
(void)
- exactly zero arguments.anything with
...
is a variadic argument list - those are placed differently on the stack and won't work with functions that have for example 4 parameters.The goal here is to increase type safety if no explicit casts are done. I'll possibly inspect the optional use of libffi in a bunch of days, but I guess that this may only work correctly (for COBOL where you may omit trailing OPTIONAL arguments) if the previously loaded caller provides metadata about the amount of arguments - and those are used... which is actually a good idea for 4.x, so maybe I inspect libffi "more later"...
What I may do earlier is replacing the union by a simple void
*func (void)
and then always cast... but I may have tried that before running into compiler warnings (clang?) about "bad practice, may break at runtime".Thank you for these explanations.
I will revert the
...
and await any further info from you. In the meantime, I can also simply add theCC="gcc -std=gnu17"
line. Is GnuCOBOL v3 still developed, or is development supposed to only go into v4, meaning that you would rather spend your time on v4?We (@ddeclerck does the work and necessary adjustments, I'm doing the review) are in the process of merging 3.x to 4.x. In any case there will be a 3.3 release this year (maybe in 2 months) and I'm indeed mostly working on the 3.x branch. It is not clear yet if 3.3 will be the last release of the 3.x version, but focus will go to 4 as well as V-ISAM after its release.
Note: 3.2 had translation updates, you possibly want to update French, German and Serbian manually. Side note: I'll drop any translation from the distribution that doesn't have more than 50% translated before the 3.3 release, so Spanish, Turkish and Swedish may or may not stay in (depending on translators which I'll send a friendly ping after the first 3.3rc).
Thanks!
I looked at Gentoo, and they have a patch for C23. I can't judge it and will just leave it here.