Question

I am currently looking through the OpenCV implementation of FAST and stumbled upon some variables which are cast to void. I understand that this is used to silence lint/compiler warnings, when a variable is not used. But in this case the variables are used. It might be related to SSE, since it only happens in those code parts.

#if CV_SSE2
    __m128i delta = _mm_set1_epi8(-128), t = _mm_set1_epi8((char)threshold), K16 = _mm_set1_epi8((char)K);
    (void)K16;
    (void)delta;
    (void)t;
#endif

Later usages (edit):

#if CV_SSE2
...
__m128i v1 = _mm_xor_si128(_mm_subs_epu8(v0, t), delta);
...
int m = _mm_movemask_epi8(_mm_cmpgt_epi8(max0, K16));
...
#endif

See also: full fast.cpp in the OpenCV-Repository (the code I pasted is from line 71 onwards)

So, what is it good for and why only for SSE related variables?

Était-ce utile?

La solution

If you look at the blame for those lines, they were added in this commit, with commit message "warnings under windows".

You could ask the committer, https://github.com/CheeseWiz, but I'd suspect it just comes down to a bug in MSVC.

Autres conseils

Though it's compiler dependent, it's typically used to surpress "unused variable" messages.

I prefer the UNUSED(var) macro, as it clearly shows the intent and can be customized to various compiler environments.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top