Skip to content

Unified Headers: LONG_BIT Undeclared in legacy_signal_inlines.h When APP_API < 21 #352

@epicstar

Description

@epicstar

Description

When compiling one of my company's products, when enabling Unified Headers and APP_API < 21, I get the following error:

Android/Sdk/ndk-bundle/sysroot/usr/include/android/legacy_signal_inlines.h:52:33: error: use of undeclared identifier 'LONG_BIT'

This seems to be happening when trying to compile one of my product's files, which depends on Boost's atomic library:

In file included from ${HOME_FOLDER}/${LIB_FOLDER}/boost/include/boost/atomic.hpp:12:
In file included from ${HOME_FOLDER}/${LIB_FOLDER}/boost/include/boost/atomic/atomic.hpp:19:
In file included from ${HOME_FOLDER}/${LIB_FOLDER}/boost/include/boost/atomic/capabilities.hpp:17:
In file included from ${HOME_FOLDER}/${LIB_FOLDER}/boost/include/boost/atomic/detail/config.hpp:18:
In file included from ${HOME_FOLDER}/${LIB_FOLDER}/boost/include/boost/config.hpp:57:
In file included from ${HOME_FOLDER}/${LIB_FOLDER}/boost/include/boost/config/platform/linux.hpp:74:
In file included from ${HOME_FOLDER}/${LIB_FOLDER}/boost/include/boost/config/posix_features.hpp:18:
In file included from ${HOME_FOLDER}/Android/Sdk/ndk-bundle/sysroot/usr/include/unistd.h:35:
In file included from ${HOME_FOLDER}/Android/Sdk/ndk-bundle/sysroot/usr/include/sys/select.h:36:
In file included from ${HOME_FOLDER}/Android/Sdk/ndk-bundle/sysroot/usr/include/signal.h:188:
${HOME_FOLDER}/Android/Sdk/ndk-bundle/sysroot/usr/include/android/legacy_signal_inlines.h:52:33: error: use of undeclared identifier 'LONG_BIT'
  return (int)((local_set[bit / LONG_BIT] >> (bit % LONG_BIT)) & 1);
                                ^
${HOME_FOLDER}Android/Sdk/ndk-bundle/sysroot/usr/include/android/legacy_signal_inlines.h:52:53: error: use of undeclared identifier 'LONG_BIT'
  return (int)((local_set[bit / LONG_BIT] >> (bit % LONG_BIT)) & 1);
                                                    ^
${HOME_FOLDER}Android/Sdk/ndk-bundle/sysroot/usr/include/android/legacy_signal_inlines.h:63:19: error: use of undeclared identifier 'LONG_BIT'
  local_set[bit / LONG_BIT] |= 1UL << (bit % LONG_BIT);
                  ^
${HOME_FOLDER}Android/Sdk/ndk-bundle/sysroot/usr/include/android/legacy_signal_inlines.h:63:46: error: use of undeclared identifier 'LONG_BIT'
  local_set[bit / LONG_BIT] |= 1UL << (bit % LONG_BIT);
                                             ^
${HOME_FOLDER}/Android/Sdk/ndk-bundle/sysroot/usr/include/android/legacy_signal_inlines.h:75:19: error: use of undeclared identifier 'LONG_BIT'
  local_set[bit / LONG_BIT] &= ~(1UL << (bit % LONG_BIT));
                  ^
${HOME_FOLDER}Android/Sdk/ndk-bundle/sysroot/usr/include/android/legacy_signal_inlines.h:75:48: error: use of undeclared identifier 'LONG_BIT'
  local_set[bit / LONG_BIT] &= ~(1UL << (bit % LONG_BIT));

Investigating this slightly further, I found a couple things....

  • If I set my APP_API level to 21, I no longer get this problem (obviously x86_64 and arm64-v8a will never get this problem anyway). This is probably because it never goes into the legacy_signal_inlines.h
  • I get the same issue without the unified headers disabled, at around the same equivalent header files:
In file included from ${HOME_FOLDER}/${LIB_FOLDER}/boost/include/boost/config/posix_features.hpp:18:
In file included from ${HOME_FOLDER}/Android/Sdk/ndk-bundle/platforms/android-19/arch-arm/usr/include/unistd.h:34:
In file included from ${HOME_FOLDER}/Android/Sdk/ndk-bundle/platforms/android-19/arch-arm/usr/include/sys/select.h:34:
${HOME_FOLDER}/Android/Sdk/ndk-bundle/platforms/android-19/arch-arm/usr/include/signal.h:67:36: error: use of undeclared identifier 'LONG_BIT'
    return (int)((local_set[signum/LONG_BIT] >> (signum%LONG_BIT)) & 1);
  • LONG_BIT is actually defined in the following header file: ${HOME_FOLDER}/Android/Sdk/ndk-bundle/sysroot/usr/include/limits.h
  • However, legacy_signals_inlines.h doesn't have limits.h included:
#include <errno.h>
#include <signal.h>
#include <string.h>
#include <sys/cdefs.h>

My opinions:

  • This is definitely not a regression at all since the old headers had the same exact issue. However, I would've expected unified headers to essentially fix problems like what I'm seeing now
  • Seems like the old platform headers were loading header files either in the wrong order or this this header file was never actually fully tested.

To me, this is obviously a bug in both the old headers and in the new unified headers code. How long will it take to fix this? I really hope there's a patch version of r14 to fix small issues like this.

Environment Details

Not all of these will be relevant to every bug, but please provide as much
information as you can.

  • NDK Version: 14.1.3816874
  • Build sytem: ndk-build
  • Host OS: Linux (Ubuntu 16.04)
  • Compiler: Clang
  • ABI: armeabi-v7a
  • STL: c++_shared
  • NDK API level: 19
  • Device API level: N/A

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions