DEMCON / libstored

Generator for a store--a set of variables--to be embedded in an application, with fast store access via C++ and VHDL, data synchronization between processes, and remote access for the Embedded Debugger.
https://demcon.github.io/libstored
Mozilla Public License 2.0
10 stars 2 forks source link

Error trying to use FilterFirstOrder component: `call to non-'constexpr' function 'void __assert_func()` #53

Closed RobertoRoos closed 1 year ago

RobertoRoos commented 1 year ago

I was trying to add a FilterFirstOrder object, but I can't get it to compile.

I have the following store:

...

{
    ...

    {
        (float) sample frequency (Hz)
        float=1.0 cutoff frequency (Hz)
    } lowpass filter

} loadcell

And the following code:

constexpr auto filter_o =
        stored::LowPass<stored::MainStore>::objects("/loadcell/lowpass_filter/");

I get this compile error:

[build] /project/extern/libstored/include/libstored/components.h:311:16:   in 'constexpr' expansion of 'stored::FreeObjects<stored::FreeFunction<float, stored::MainStore>, 's'>::find<43>(((const char (&)[43])(& buf)), stored::FreeFunction<float, stored::MainStore>())'
[build] /project/extern/libstored/include/libstored/components.h:343:48:   in 'constexpr' expansion of 'stored::MainStoreBase<stored::MainStore>::freeFunction<float>(((const char*)name), 43)'
[build] /project/dist/fumo/build/root/app/my_app/libstored/include/MainStore.h:1108:41:   in 'constexpr' expansion of 'stored::impl::find(stored::MainStoreData::shortDirectory(), name, len).stored::Variant<void>::function<float, stored::MainStore>()'
[build] /project/extern/libstored/include/libstored/util.h:237:6: error: call to non-'constexpr' function 'void __assert_func(const char*, int, const char*, const char*)'
[build]   237 |      assert(expr);                \
[build]       |      ^~~~~~
[build] /project/extern/libstored/include/libstored/types.h:1973:3: note: in expansion of macro 'stored_assert'
[build]  1973 |   stored_assert(isFunction());
[build]       |   ^~~~~~~~~~~~~

Why is assert() not compatible with constexpr for me?

RobertoRoos commented 1 year ago

Hm, I was missing the function definition for sample frequency (Hz), with it it compiles and runs fine. That seems odd though, and I don't understand the compiler error.

RobertoRoos commented 1 year ago

@jhrutgers explains the problem might have been the default implementation of sample frequency (Hz), which might not be compatible with constexpr.