ETLCPP / etl

Embedded Template Library
https://www.etlcpp.com
MIT License
2.05k stars 372 forks source link

Declaration order for etl::first_set_bit_position in binary.h #827

Closed omar-droubi closed 2 months ago

omar-droubi commented 5 months ago

When using the function etl::first_set_bit_position in binary.h, compilation fails due to declaration order. etl::first_set_bit_position relies on etl::count_trailing_zeros which is declared after wards.

#include "etl/binary.h"

int main()
{
    auto pos = etl::first_set_bit_position(0xAA);
    std::cout << pos << std::endl;
    return 0;
}
binary.h:354:12: error: call to function 'count_trailing_zeros' that is neither visible in the template definition nor found by argument-dependent lookup
    return count_trailing_zeros(value);
           ^
main.cpp:12:21: note: in instantiation of function template specialization 'etl::first_set_bit_position<int>' requested here
    auto pos = etl::first_set_bit_position(0xAA);
                    ^
bsw/common/etl/include/etl/binary.h:1361:5: note: 'count_trailing_zeros' should be declared prior to the call site
    count_trailing_zeros(T value)
    ^
1 error generated.

etl::first_set_bit_position definition should be moved till after the definition of etl::count_trailing_zeros.

jwellbelove commented 2 months ago

Fixed 20.38.11