Workaround to get codes to work in MSVC++ 2010 due to “Type name is not allowed”

左心房为你撑大大i 提交于 2019-12-08 09:19:32

问题


I am trying to implement a finger detection, which link is given here. Am I am going through the code in MSVC2010, it gives me error as shown in Figure as shown below. Could someone tell me why the following codes gives me error? Is this related to these following questions; 1, 2, 3? Is there a possible workaround? I already included:

#include <cstdint> 
#include <stdint.h>

I also tried:

unsigned short depth = (unsigned short) (v[2] * 1000.0f); // hand depth
unsigned short near = (unsigned short) (depth - 100); // near clipping plane
unsigned short far = (unsigned short) (depth + 100); // far clipping plane

but did not work.

Thanks,

ikel


回答1:


The reason is that near and far are already #defined elsewhere as something else. This is typical if you have already included windows.h, which includes windef.h with following macros:

#define far
#define near
#if (!defined(_MAC)) && ((_MSC_VER >= 800) || defined(_STDCALL_SUPPORTED))
#define pascal __stdcall
#else
#define pascal
#endif

Try changing names into something like plane_near and plane_far and it will work.



来源:https://stackoverflow.com/questions/12454961/workaround-to-get-codes-to-work-in-msvc-2010-due-to-type-name-is-not-allowed

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!