liuliu / ccv

C-based/Cached/Core Computer Vision Library, A Modern Computer Vision Library
http://libccv.org
Other
7.08k stars 1.71k forks source link

undefined identifier for_block in ccv for Visual C++ #202

Closed wandering007 closed 7 years ago

wandering007 commented 7 years ago

I am currently trying to make ccv work on Visual C++ (Visual Studio 2015). Most C99 code is easy to tranformed to MSVC-style. However, the following code problem is haunting me:

void ccv_shift(ccv_matrix_t* a, ccv_matrix_t** b, int type, int lr, int rr)
{
    ccv_dense_matrix_t* da = ccv_get_dense_matrix(a);
    ccv_declare_derived_signature(sig, da->sig != 0, ccv_sign_with_format(64, "ccv_shift(%d,%d)", lr, rr), da->sig, CCV_EOF_SIGN);
    type = (type == 0) ? CCV_GET_DATA_TYPE(da->type) | CCV_GET_CHANNEL(da->type) : CCV_GET_DATA_TYPE(type) | CCV_GET_CHANNEL(da->type);
    *b = ccv_dense_matrix_renew((ccv_dense_matrix_t*)(*b), da->rows, da->cols, CCV_ALL_DATA_TYPE | CCV_GET_CHANNEL(da->type), type, sig);
    ccv_dense_matrix_t* db = (ccv_dense_matrix_t*)(*b);
    ccv_object_return_if_cached(, db);
    int i, j, ch = CCV_GET_CHANNEL(da->type);
    unsigned char* aptr = da->data.u8;
    unsigned char* bptr = db->data.u8;
#define for_block(_for_get, _for_set) \
    for (i = 0; i < da->rows; i++) \
    { \
        for (j = 0; j < da->cols * ch; j++) \
        { \
            _for_set(bptr, j, _for_get(aptr, j, lr), rr); \
        } \
        aptr += da->step; \
        bptr += db->step; \
    }
    ccv_matrix_getter(da->type, ccv_matrix_setter, db->type, for_block);
#undef for_block
}

The MSVC compiler tells me that function ccv_matrix_getter error:

#define ccv_matrix_getter(type, block, ...) { switch (CCV_GET_DATA_TYPE(type)) { \
    case CCV_32S: { block(__VA_ARGS__, _ccv_get_32s_value); break; } \
    case CCV_32F: { block(__VA_ARGS__, _ccv_get_32f_value); break; } \
    case CCV_64S: { block(__VA_ARGS__, _ccv_get_64s_value); break; } \
    case CCV_64F: { block(__VA_ARGS__, _ccv_get_64f_value); break; } \
    default: { block(__VA_ARGS__, _ccv_get_8u_value); } } }

undefined identifier: "for_block"

I am not familiar with C99 and don't know what for_block do.I really need help.

liuliu commented 7 years ago

The VC++ is not a supported compiler. You an try Mingw32 / 64 to compile to static library and then link against your main VC++ project. The problem is MS's C compiler is not standard conforming (MS's C compiler is reduced from its C++ compiler) and will not respect standard macro. There may be workaround to make it compilable but I don't have a Windows machine to validate the fix.

wandering007 commented 7 years ago

@liuliu Thanks. I'll try it.