Skip to content

use of undeclared identifier 'UINT8_MAX' #451

Closed

Description

@biyunhuang

hello, i meet this error , json.hpp:6365:59: error: use of undeclared identifier 'UINT8_MAX',
Can someone help me with this question?

i compile in ndk , the version is ndk-r10e
this is my content in application.mk:

APP_STL := c++_shared
NDK_TOOLCHAIN_VERSION := clang3.6
APP_CPPFLAGS += -std=c++11 -frtti -fexceptions
APP_PLATFORM = android-19 (if android-21 ,Will not have this problem)

Activity

  1. nlohmann commented on Feb 14, 2017

    @nlohmann
    Owner

    From http://stackoverflow.com/questions/16748392/cant-find-symbols-in-stdint-h:

    The macros are available when __STDC_LIMIT_MACROS is defined (additionally __STDC_CONSTANT_MACROS seems to be missing as well). This is probably incorrectly gated or missing when compiling c++. Objective-C and C pick up on these defines for UINT8_MAX and accompanying macros. For now you can define both of those macros globally and it should have no ill effects on your project.

    Could you try to define __STDC_LIMIT_MACROS when compiling your code?

  2. biyunhuang commented on Feb 15, 2017

    @biyunhuang
    Author

    @nlohmann oh yeah, it's helpful for me, thank you very much!

  3. nlohmann commented on Feb 15, 2017

    @nlohmann
    Owner

    Good to hear. I shall add a comment to the README.

  4. added this to the Release 2.1.1 milestone on Feb 15, 2017
  5. TurpentineDistillery commented on Feb 15, 2017

    @TurpentineDistillery

    Why not use numeric_limits here, considering that they are already used elsewhere?

  6. nlohmann commented on Feb 15, 2017

    @nlohmann
    Owner

    Good point!

  7. added a commit that references this issue on Feb 15, 2017
  8. nlohmann commented on Feb 15, 2017

    @nlohmann
    Owner

    I replaced the macros with calls to numeric_limits. @biyunhuang Could you try the current version if it works without the need of defining __STDC_LIMIT_MACROS?

  9. nlohmann commented on Feb 19, 2017

    @nlohmann
    Owner

    @biyunhuang Could you please try the current version if it works without the need of defining __STDC_LIMIT_MACROS?

  10. nlohmann commented on Feb 21, 2017

    @nlohmann
    Owner

    I could reproduce the original error as well as verify it is fixed with the current version with the following configuration:

    Application.mk

    APP_ABI := x86
    APP_PLATFORM := android-19
    NDK_TOOLCHAIN_VERSION := clang3.6
    APP_STL := c++_shared
    APP_BUILD_SCRIPT := Android.mk
    

    Android.mk

    LOCAL_PATH := .
    include $(CLEAR_VARS)
    LOCAL_MODULE := testfile.out
    LOCAL_SRC_FILES := testfile.cpp
    LOCAL_C_INCLUDES += src
    LOCAL_CPP_FEATURES += exceptions rtti
    LOCAL_CPPFLAGS += -fexceptions -frtti -std=c++11
    include $(BUILD_EXECUTABLE)
    

    testfile.cpp

    #include <json.hpp>
    
    using json = nlohmann::json;
    
    int main()
    {
        json j = 1;
    }

    and Android NDK r10e from https://github.com/android-ndk/ndk/wiki.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions