“CompileTimeError” 编译报错的分析
加入如下代码之后编译报错
CONFIG_FEATURE_SI(
FID_AE_STROBE,
BY_DEFAULT(FLASHLIGHT_FORCE_OFF),
FLASHLIGHT_FORCE_ON, FLASHLIGHT_FORCE_OFF
)
编译器报错提示:
mediatek/platform/mt6572/hardware/camera/custom/imgsensor/../hal/imgsensor/cfg_ftbl_gc2035_yuv.h:148:1:
error: aggregate 'NSFeature::CompileTimeError<0> ERROR_FID_AE_STROBE__NOT_scene_indep' has incomplete type and cannot be defined
Import includes file: out/target/product/mbk72_wet_lca/obj/SHARED_LIBRARIES/libcam_camera_exif_intermediates/import_includes
target thumb C++: libcam.exif.common <= mediatek/hard
#define CHECK_FID_YUV_SI(_fid) \ // Fid2Type<_fid>::Info::isYUVSceneIndep = 0;
STATIC_CHECK(Fid2Type<_fid>::Info::isYUVSceneIndep, _fid##__NOT_scene_indep)
// _fid 满足8~23 之间是数字,则 Fid2Type<_fid>::Info::isYUVSceneIndep = 1;
// 才满足 CompileTimeError 中的 ((expr) != 0
mediatek/custom/common/hal/inc/camera_feature/camera_feature_utility.h
Fid2Type<_fid>::Info
#define STATIC_CHECK(expr, msg) \
{ CompileTimeError<((expr) != 0)> ERROR_##msg; (void)ERROR_##msg; }
// 如果 expr 为true 即不为 0,那就编译通过,如果等于0,那就编译报错。而expr最终等于 Fid2Type<_fid>::Info::isYUVSceneIndep ,所以报错了。
#define CHECK_FID_SI CHECK_FID_YUV_SI
#define CHECK_FID_SD CHECK_FID_YUV_SD
template <MUINT32 v>
struct
Int2Type
{
enum { value = v };
};
template<MBOOL> struct CompileTimeError;
template<> struct CompileTimeError<MTRUE> {};
CONFIG_FEATURE_SI(FID_AE_STROBE,
BY_DEFAULT(FLASHLIGHT_FORCE_OFF),
FLASHLIGHT_FORCE_ON, FLASHLIGHT_FORCE_OFF
#define CONFIG_FEATURE_SI(_fid, _default_macro, _table...) \
_CONFIG_FEATURE(_fid, Fid2Type<_fid>::Type) \
CHECK_FID_SI(_fid); \ // _fid =FID_AE_STROBE
_default_macro \
static type aTable[] = { _table }; \
_END_CONFIG_FEATURE()
#define _CONFIG_FEATURE(_fid, _ftype) \
case _fid: \
{ __CONFIG_FEATURE(_fid, _ftype)