Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use of undeclared identifier 'UINT8_MAX' #451

Closed
biyunhuang opened this issue Feb 14, 2017 · 8 comments
Closed

use of undeclared identifier 'UINT8_MAX' #451

biyunhuang opened this issue Feb 14, 2017 · 8 comments

Comments

@biyunhuang
Copy link

biyunhuang commented Feb 14, 2017

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)

@nlohmann nlohmann added kind: bug platform: android related to Android NDK labels Feb 14, 2017
@nlohmann
Copy link
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?

@biyunhuang
Copy link
Author

biyunhuang commented Feb 15, 2017

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

@nlohmann
Copy link
Owner

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

@nlohmann nlohmann added this to the Release 2.1.1 milestone Feb 15, 2017
@TurpentineDistillery
Copy link

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

@nlohmann
Copy link
Owner

Good point!

@nlohmann
Copy link
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?

@nlohmann
Copy link
Owner

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

@nlohmann nlohmann added the state: please discuss please discuss the issue or vote for your favorite option label Feb 19, 2017
@nlohmann
Copy link
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
Labels
Projects
None yet
Development

No branches or pull requests

3 participants