Bugzilla – Bug 1001
build error expected declaration specifiers or '...' before '(' token
Last modified: 2022-01-27 19:54:08 MST
We are using quite old kernel (2.6.23+custom patches) and try to cross compile recent version of sudo for sh4 platform. It seems the configure script enable some workarounds from include/sudo_compat.h and here we get the errors like this one: ../../include/sudo_compat.h:595:35: error: expected declaration specifiers or '...' before '(' token 595 | # define pipe2(_a, _b) sudo_pipe2((_a), (_b)) The preprocessed output (simplified for human reading): extern int sudo_pipe2(( int __pipedes[2] ), ( int __flags )) __attribute__ ((__nothrow__ , __leaf__)) ; I've tried different version of GCC and no one can't compile it. For example Debian gcc output: $ gcc --version gcc (Debian 8.3.0-6) 8.3.0 Copyright (C) 2018 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. $ cat a.c extern int sudo_pipe2((int __pipedes[2]), (int __flags)) __attribute__ ((__nothrow__ , __leaf__)) ; $ gcc a.c a.c:1:23: error: expected declaration specifiers or '...' before '(' token extern int sudo_pipe2((int __pipedes[2]), (int __flags)) __attribute__ ((__nothrow__ , __leaf__)) ; ^ a.c:1:43: error: expected declaration specifiers or '...' before '(' token extern int sudo_pipe2((int __pipedes[2]), (int __flags)) __attribute__ ((__nothrow__ , __leaf__)) ;
This is usually due to a mismatch between the header files and the C library. It sounds like pipe2 is not present in the sh4 libc so sudo tries to use its own version but there actually is a pipe2 prototype in the headers you are using. If you cannot fix the header files, adding: #include <unistd.h> to sudo_compat.h may work around the problem.
That is right, uClibc-ng header has pipe2, dup3 function declarations while implementation is not defined for such old kernel (no ioctls). I've added function definition (by using another ioctls) and compilation went well. Obviously in this case sudo's workaround macro is not enabled.
sudo_compat.h now includes unistd.h which should avoid the header issue