serge1/ELFIO

No adhering to ISO C++

pmor13 opened this issue · 4 comments

The elfio.pdf says:

Adhering to ISO C++

Well, ISO C++ does not have strnlen.

Hence an ISO C++ compiler (e.g. g++ -std=c++17) won't build ELFIO:

./elfio/elfio_strings.hpp: In instantiation of ‘const char* ELFIO::string_section_accessor_template<S>::get_string(ELFIO::Elf_Word) const [with S = ELFIO::section; ELFIO::Elf_Word = unsigned int]’:
./elfio/elfio.hpp:521:54:   required from here
./elfio/elfio_strings.hpp:49:28: error: ‘strnlen’ was not declared in this scope; did you mean ‘strlen’?
   49 |                     strnlen( data + index, string_section->get_size() - index );
      |                     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                     strlen

Hi,

The function is not a part of C++ standard, but, it is a part of POSIX.

I was not able to get this error when using the following command line:
g++-12 -std=c++17 -Wall -Wextra -pedantic -Werror -I../.. elfdump.cpp -o elfdump

The library was checked by g++, clang++ and MSVS C++ compilers on Intel processors.
What processor architecture you compile for?

In GNU header file string.h, availability of strnlen() is managed by define __USE_XOPEN2K8.
Please see dedicated thread at StackOverflow

Due to no activity, I'm closing the issue. Feel free to reopen if required.

serge1 commented

The issue is addressed in commit 089160c