JDAI-CV / DNNLibrary

Daquexian's NNAPI Library. ONNX + Android NNAPI
Apache License 2.0
346 stars 59 forks source link

error: use of undeclared identifier '__ANDROID_API_Q__' #72

Closed CAMOBAP closed 3 months ago

CAMOBAP commented 4 years ago

Problem

Per README:

... you need Android NDK, r17b or higher NDK is necessary

But in fact, in code used definition which available only in r19 https://github.com/JDAI-CV/DNNLibrary/blob/master/dnnlibrary/ModelBuilder.cpp#L358

Workaround

Pass -D__ANDROID_API_Q__=29 to preprocessor

Long-term solution

To me, the idea of using __ANDROID_API_XXX__ looks great, so maybe it will be good to wrap up this if with

#ifndef __ANDROID_API_Q__
   return return dnn::nullopt;
#else
   ...
#endif

P.S. You may ask "Wouldn't it be easier to upgrade the NDK?" and generally answer is yes but sometimes project have a strong dependency on specific NDK revision or use custom "non-vanilla" NDK

I can help with preparing PR if a general idea is good, or with any other suggested way