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

Tests fail to compile: error: function definition is not allowed here, etc #23

Open
yurivict opened this issue Jul 3, 2022 · 3 comments

Comments

@yurivict
Copy link

yurivict commented Jul 3, 2022

[ 11% 6/9] /usr/bin/cc  -I/disk-samsung/freebsd-ports/devel/libcsptr/work/libcsptr-2.0.4-24-gac73451/check/../include -O2 -pipe -fno-omit-frame-pointer  -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing -Wall -Wextra -Werror -g -std=gnu99 -Wno-unused-result -Wno-missing-field-initializers -O2 -pipe -fno-omit-frame-pointer  -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing -MD -MT check/CMakeFiles/check_unit.dir/test/misc.c.o -MF check/CMakeFiles/check_unit.dir/test/misc.c.o.d -o check/CMakeFiles/check_unit.dir/test/misc.c.o -c /disk-samsung/freebsd-ports/devel/libcsptr/work/libcsptr-2.0.4-24-gac73451/check/test/misc.c
FAILED: check/CMakeFiles/check_unit.dir/test/misc.c.o 
/usr/bin/cc  -I/disk-samsung/freebsd-ports/devel/libcsptr/work/libcsptr-2.0.4-24-gac73451/check/../include -O2 -pipe -fno-omit-frame-pointer  -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing -Wall -Wextra -Werror -g -std=gnu99 -Wno-unused-result -Wno-missing-field-initializers -O2 -pipe -fno-omit-frame-pointer  -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing -MD -MT check/CMakeFiles/check_unit.dir/test/misc.c.o -MF check/CMakeFiles/check_unit.dir/test/misc.c.o.d -o check/CMakeFiles/check_unit.dir/test/misc.c.o -c /disk-samsung/freebsd-ports/devel/libcsptr/work/libcsptr-2.0.4-24-gac73451/check/test/misc.c
/disk-samsung/freebsd-ports/devel/libcsptr/work/libcsptr-2.0.4-24-gac73451/check/test/misc.c:14:42: error: function definition is not allowed here
        lambda(void *, (UNUSED size_t s) { return NULL; }),
                                         ^
/disk-samsung/freebsd-ports/devel/libcsptr/work/libcsptr-2.0.4-24-gac73451/check/test/misc.c:14:9: error: use of undeclared identifier '__fn__'
        lambda(void *, (UNUSED size_t s) { return NULL; }),
        ^
/disk-samsung/freebsd-ports/devel/libcsptr/work/libcsptr-2.0.4-24-gac73451/check/test/utils.h:40:51: note: expanded from macro 'lambda'
#define lambda(RType, Body) ({ RType __fn__ Body; __fn__; })
                                                  ^
/disk-samsung/freebsd-ports/devel/libcsptr/work/libcsptr-2.0.4-24-gac73451/check/test/misc.c:15:41: error: function definition is not allowed here
        lambda(void, (UNUSED void *ptr) {})
                                        ^
/disk-samsung/freebsd-ports/devel/libcsptr/work/libcsptr-2.0.4-24-gac73451/check/test/misc.c:15:9: error: use of undeclared identifier '__fn__'
        lambda(void, (UNUSED void *ptr) {})
        ^
/disk-samsung/freebsd-ports/devel/libcsptr/work/libcsptr-2.0.4-24-gac73451/check/test/utils.h:40:51: note: expanded from macro 'lambda'
#define lambda(RType, Body) ({ RType __fn__ Body; __fn__; })
                                                  ^
/disk-samsung/freebsd-ports/devel/libcsptr/work/libcsptr-2.0.4-24-gac73451/check/test/misc.c:14:9: error: initializing 'void *(*)(size_t)' (aka 'void *(*)(unsigned long)') with an expression of incompatible type 'void'
        lambda(void *, (UNUSED size_t s) { return NULL; }),
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/disk-samsung/freebsd-ports/devel/libcsptr/work/libcsptr-2.0.4-24-gac73451/check/test/utils.h:40:29: note: expanded from macro 'lambda'
#define lambda(RType, Body) ({ RType __fn__ Body; __fn__; })
                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/disk-samsung/freebsd-ports/devel/libcsptr/work/libcsptr-2.0.4-24-gac73451/check/test/misc.c:15:9: error: initializing 'void (*)(void *)' with an expression of incompatible type 'void'
        lambda(void, (UNUSED void *ptr) {})
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/disk-samsung/freebsd-ports/devel/libcsptr/work/libcsptr-2.0.4-24-gac73451/check/test/utils.h:40:29: note: expanded from macro 'lambda'
#define lambda(RType, Body) ({ RType __fn__ Body; __fn__; })
                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
6 errors generated.
[ 22% 6/9] /usr/bin/cc -Dcsptr_EXPORTS -I/disk-samsung/freebsd-ports/devel/libcsptr/work/libcsptr-2.0.4-24-gac73451/include/csptr -I/disk-samsung/freebsd-ports/devel/libcsptr/work/libcsptr-2.0.4-24-gac73451/src -O2 -pipe -fno-omit-frame-pointer  -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing -Wall -Wextra -Werror -g -std=gnu99 -Wno-unused-result -Wno-missing-field-initializers -O2 -pipe -fno-omit-frame-pointer  -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing -fPIC   -fPIC -MD -MT CMakeFiles/csptr.dir/src/array.c.o -MF CMakeFiles/csptr.dir/src/array.c.o.d -o CMakeFiles/csptr.dir/src/array.c.o -c /disk-samsung/freebsd-ports/devel/libcsptr/work/libcsptr-2.0.4-24-gac73451/src/array.c
[ 33% 6/9] /usr/bin/cc  -I/disk-samsung/freebsd-ports/devel/libcsptr/work/libcsptr-2.0.4-24-gac73451/check/../include -O2 -pipe -fno-omit-frame-pointer  -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing -Wall -Wextra -Werror -g -std=gnu99 -Wno-unused-result -Wno-missing-field-initializers -O2 -pipe -fno-omit-frame-pointer  -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing -MD -MT check/CMakeFiles/check_unit.dir/test/scalar.c.o -MF check/CMakeFiles/check_unit.dir/test/scalar.c.o.d -o check/CMakeFiles/check_unit.dir/test/scalar.c.o -c /disk-samsung/freebsd-ports/devel/libcsptr/work/libcsptr-2.0.4-24-gac73451/check/test/scalar.c
FAILED: check/CMakeFiles/check_unit.dir/test/scalar.c.o 
/usr/bin/cc  -I/disk-samsung/freebsd-ports/devel/libcsptr/work/libcsptr-2.0.4-24-gac73451/check/../include -O2 -pipe -fno-omit-frame-pointer  -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing -Wall -Wextra -Werror -g -std=gnu99 -Wno-unused-result -Wno-missing-field-initializers -O2 -pipe -fno-omit-frame-pointer  -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing -MD -MT check/CMakeFiles/check_unit.dir/test/scalar.c.o -MF check/CMakeFiles/check_unit.dir/test/scalar.c.o.d -o check/CMakeFiles/check_unit.dir/test/scalar.c.o -c /disk-samsung/freebsd-ports/devel/libcsptr/work/libcsptr-2.0.4-24-gac73451/check/test/scalar.c
/disk-samsung/freebsd-ports/devel/libcsptr/work/libcsptr-2.0.4-24-gac73451/check/test/scalar.c:13:76: error: function definition is not allowed here
    f_destructor dtor = lambda(void, (UNUSED void *ptr, UNUSED void *meta) { dtor_run = 1; });
                                                                           ^
/disk-samsung/freebsd-ports/devel/libcsptr/work/libcsptr-2.0.4-24-gac73451/check/test/scalar.c:13:25: error: use of undeclared identifier '__fn__'
    f_destructor dtor = lambda(void, (UNUSED void *ptr, UNUSED void *meta) { dtor_run = 1; });
                        ^
/disk-samsung/freebsd-ports/devel/libcsptr/work/libcsptr-2.0.4-24-gac73451/check/test/utils.h:40:51: note: expanded from macro 'lambda'
#define lambda(RType, Body) ({ RType __fn__ Body; __fn__; })
                                                  ^
/disk-samsung/freebsd-ports/devel/libcsptr/work/libcsptr-2.0.4-24-gac73451/check/test/scalar.c:13:18: error: initializing 'f_destructor' (aka 'void (*)(void *, void *)') with an expression of incompatible type 'void'
    f_destructor dtor = lambda(void, (UNUSED void *ptr, UNUSED void *meta) { dtor_run = 1; });
                 ^      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/disk-samsung/freebsd-ports/devel/libcsptr/work/libcsptr-2.0.4-24-gac73451/check/test/scalar.c:30:76: error: function definition is not allowed here
    f_destructor dtor = lambda(void, (UNUSED void *ptr, UNUSED void *meta) { dtor_run = 1; });
                                                                           ^
/disk-samsung/freebsd-ports/devel/libcsptr/work/libcsptr-2.0.4-24-gac73451/check/test/scalar.c:30:25: error: use of undeclared identifier '__fn__'
    f_destructor dtor = lambda(void, (UNUSED void *ptr, UNUSED void *meta) { dtor_run = 1; });
                        ^
/disk-samsung/freebsd-ports/devel/libcsptr/work/libcsptr-2.0.4-24-gac73451/check/test/utils.h:40:51: note: expanded from macro 'lambda'
#define lambda(RType, Body) ({ RType __fn__ Body; __fn__; })
                                                  ^
/disk-samsung/freebsd-ports/devel/libcsptr/work/libcsptr-2.0.4-24-gac73451/check/test/scalar.c:30:18: error: initializing 'f_destructor' (aka 'void (*)(void *, void *)') with an expression of incompatible type 'void'
    f_destructor dtor = lambda(void, (UNUSED void *ptr, UNUSED void *meta) { dtor_run = 1; });
                 ^      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
6 errors generated.
[ 44% 6/9] /usr/bin/cc  -I/disk-samsung/freebsd-ports/devel/libcsptr/work/libcsptr-2.0.4-24-gac73451/check/../include -O2 -pipe -fno-omit-frame-pointer  -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing -Wall -Wextra -Werror -g -std=gnu99 -Wno-unused-result -Wno-missing-field-initializers -O2 -pipe -fno-omit-frame-pointer  -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing -MD -MT check/CMakeFiles/check_unit.dir/test/shared.c.o -MF check/CMakeFiles/check_unit.dir/test/shared.c.o.d -o check/CMakeFiles/check_unit.dir/test/shared.c.o -c /disk-samsung/freebsd-ports/devel/libcsptr/work/libcsptr-2.0.4-24-gac73451/check/test/shared.c
FAILED: check/CMakeFiles/check_unit.dir/test/shared.c.o 
/usr/bin/cc  -I/disk-samsung/freebsd-ports/devel/libcsptr/work/libcsptr-2.0.4-24-gac73451/check/../include -O2 -pipe -fno-omit-frame-pointer  -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing -Wall -Wextra -Werror -g -std=gnu99 -Wno-unused-result -Wno-missing-field-initializers -O2 -pipe -fno-omit-frame-pointer  -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing -MD -MT check/CMakeFiles/check_unit.dir/test/shared.c.o -MF check/CMakeFiles/check_unit.dir/test/shared.c.o.d -o check/CMakeFiles/check_unit.dir/test/shared.c.o -c /disk-samsung/freebsd-ports/devel/libcsptr/work/libcsptr-2.0.4-24-gac73451/check/test/shared.c
/disk-samsung/freebsd-ports/devel/libcsptr/work/libcsptr-2.0.4-24-gac73451/check/test/shared.c:13:76: error: function definition is not allowed here
    f_destructor dtor = lambda(void, (UNUSED void *ptr, UNUSED void *meta) { dtor_run = 1; });
                                                                           ^
/disk-samsung/freebsd-ports/devel/libcsptr/work/libcsptr-2.0.4-24-gac73451/check/test/shared.c:13:25: error: use of undeclared identifier '__fn__'
    f_destructor dtor = lambda(void, (UNUSED void *ptr, UNUSED void *meta) { dtor_run = 1; });
                        ^
/disk-samsung/freebsd-ports/devel/libcsptr/work/libcsptr-2.0.4-24-gac73451/check/test/utils.h:40:51: note: expanded from macro 'lambda'
#define lambda(RType, Body) ({ RType __fn__ Body; __fn__; })
                                                  ^
/disk-samsung/freebsd-ports/devel/libcsptr/work/libcsptr-2.0.4-24-gac73451/check/test/shared.c:13:18: error: initializing 'f_destructor' (aka 'void (*)(void *, void *)') with an expression of incompatible type 'void'
    f_destructor dtor = lambda(void, (UNUSED void *ptr, UNUSED void *meta) { dtor_run = 1; });
                 ^      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3 errors generated.
[ 55% 6/9] /usr/bin/cc  -I/disk-samsung/freebsd-ports/devel/libcsptr/work/libcsptr-2.0.4-24-gac73451/check/../include -O2 -pipe -fno-omit-frame-pointer  -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing -Wall -Wextra -Werror -g -std=gnu99 -Wno-unused-result -Wno-missing-field-initializers -O2 -pipe -fno-omit-frame-pointer  -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing -MD -MT check/CMakeFiles/check_unit.dir/test/test.c.o -MF check/CMakeFiles/check_unit.dir/test/test.c.o.d -o check/CMakeFiles/check_unit.dir/test/test.c.o -c /disk-samsung/freebsd-ports/devel/libcsptr/work/libcsptr-2.0.4-24-gac73451/check/test/test.c
[ 66% 6/9] /usr/bin/cc -Dcsptr_EXPORTS -I/disk-samsung/freebsd-ports/devel/libcsptr/work/libcsptr-2.0.4-24-gac73451/include/csptr -I/disk-samsung/freebsd-ports/devel/libcsptr/work/libcsptr-2.0.4-24-gac73451/src -O2 -pipe -fno-omit-frame-pointer  -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing -Wall -Wextra -Werror -g -std=gnu99 -Wno-unused-result -Wno-missing-field-initializers -O2 -pipe -fno-omit-frame-pointer  -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing -fPIC   -fPIC -MD -MT CMakeFiles/csptr.dir/src/mman.c.o -MF CMakeFiles/csptr.dir/src/mman.c.o.d -o CMakeFiles/csptr.dir/src/mman.c.o -c /disk-samsung/freebsd-ports/devel/libcsptr/work/libcsptr-2.0.4-24-gac73451/src/mman.c
ninja: build stopped: subcommand failed.

Rev. ac73451
clang-13
FreeBSD 13.1

@hcmh
Copy link

hcmh commented Jul 4, 2022

This is probably why gcc is needed according to the README.md: It uses nested functions in the tests, which are a gcc extension. Clang can do something similar using blocks, but libcsptr just uses a gcc-only nested function

@Snaipe
Copy link
Owner

Snaipe commented Jul 4, 2022

Hah, I wasn't expecting anyone to be porting libcsptr to FreeBSD :) The tests do need fixing so they don't use nested functions on clang. I guess either use regular static functions that write global state or fix lambda() so that it uses blocks on clang, since the tests require a C compiler with GNU extensions.

@hcmh
Copy link

hcmh commented Jul 5, 2022

I have added some changes here to make the tests pass with clang. As I am not really familiar with CMake, I am not sure about that part.

In total, it were quite a bit more changes than I had hoped, but it passes the tests now:

https://github.com/hcmh/libcsptr/tree/clang

I can make a pull-request with those changes if you like

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

3 participants