facil-io / cstl

facil.io C STL - a Server Toolbox Library for C, including JSON processing, hash maps, dynamic arrays, binary strings and more.
https://facil.io
MIT License
71 stars 6 forks source link

Some tests, like `array`, don't compile in `DEBUG` mode #18

Closed michaellenaghan closed 1 year ago

michaellenaghan commented 1 year ago

The problem is here:

https://github.com/facil-io/cstl/blob/9a04d28d3a8c16c6eef593c0a3870e99cd86ee0d/fio-stl/004%20state%20callbacks.h#L247-L249

That line is included in a DEBUG build, but tests like array apparently don't declare and implement the fio_thread_getpid() function. (If you force your way past the -Wimplicit-function-declaration warning you end up with a linker error.)

I'm afraid I don't yet know enough to offer a proper fix.

boazsegev commented 1 year ago

Hi @michaellenaghan ,

This is the second issue I cannot reproduce... maybe it's a machine / build issue?

I ran:

make db/examples/array

And I got:

* Building single-file header: fio-stl.h
* Building documentation: fio-stl.md
* Detected the OpenSSL library, setting HAVE_OPENSSL
* Detected the zlib library, setting HAVE_ZLIB
* Set debug flags.
* Set example flags (array)
* Compiling examples/array.c
        0.08 real         0.06 user         0.01 sys
* Linking... (tmp/array)

real    0m0.036s
user    0m0.065s
sys 0m0.017s
* Finished build (tmp/array)
* [0]: 0x16b4df008 : 42
* [1]: 0x16b4df010 : -42
michaellenaghan commented 1 year ago

You're using examples/array rather than tests/array:

$ make clean

* Building single-file header: fio-stl.h
* Building documentation: fio-stl.md
* Detected the OpenSSL library, setting HAVE_OPENSSL
* Detected the zlib library, setting HAVE_ZLIB

$ make db/tests/array

* Building single-file header: fio-stl.h
* Building documentation: fio-stl.md
* Detected the OpenSSL library, setting HAVE_OPENSSL
* Detected the zlib library, setting HAVE_ZLIB
* Set debug flags.
* Set testing flags (array)
* Compiling tests/array.c
In file included from tests/array.c:3:
./fio-stl.h:10347:25: error: call to undeclared function 'fio_thread_getpid'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
                  (int)(fio_thread_getpid()),
                        ^
1 error generated.
        0.24 real         0.18 user         0.04 sys
make: *** [tmp/tests/array.o] Error 1

I get the same results in main and pubs_clustering.

boazsegev commented 1 year ago

Oh, gotcha, thanks.

I fixed it in the pubsub_clustering branch. It's just there were missing modules when handling the DEBUG instructions.

Cheers.

michaellenaghan commented 1 year ago

Some of the other tests have the same problem: