找回密码
 注册
搜索
热搜: 回贴
  • 前程无忧官网首页 有什么好的平台可以
  • 最新的销售平台 互联网营销的平台有哪
  • 制作网页的基本流程 网页制作和网页设
  • 【帝国CMS】输出带序号的列表(数字排
  • 网站建设公司 三一,中联,极东泵车的
  • 织梦 建站 织梦网站模版后台怎么更改
  • 云服务官网 哪些网站有免费的简历模板
  • 如何建网站要什么条件 建网站要用什么
  • 吉林市移动公司电话 吉林省退休人员网
  • 设计类毕业论文 网站设计与实现毕业论
查看: 1481|回复: 6

[讨论]为何出现“illegal use of this type as an expression”这种编译错误 ..

[复制链接]
发表于 2009-11-4 01:38:48 | 显示全部楼层 |阅读模式 IP:江苏扬州
//////////////////////////////////////////////////////////
// Rotate a frame around it's local X axis
void gltRotateFrameLocalX(GLTFrame *pFrame, GLfloat fAngle)
{
GLTMatrix mRotation;
GLTVector3 vCross;

gltVectorCrossProduct(vCross, pFrame->vUp, pFrame->vForward);
gltRotationMatrix(fAngle, vCross[0], vCross[1], vCross[2], mRotation);
GLTVector3 vNewVect;
// Inline 3x3 matrix multiply for rotation only
vNewVect[0] = mRotation[0] * pFrame->vForward[0] + mRotation[4] * pFrame->vForward[1] + mRotation[8] * pFrame->vForward[2];
vNewVect[1] = mRotation[1] * pFrame->vForward[0] + mRotation[5] * pFrame->vForward[1] + mRotation[9] * pFrame->vForward[2];
vNewVect[2] = mRotation[2] * pFrame->vForward[0] + mRotation[6] * pFrame->vForward[1] + mRotation[10] * pFrame->vForward[2];
memcpy(pFrame->vForward, vNewVect, sizeof(GLfloat)*3);
// Update pointing up vector
vNewVect[0] = mRotation[0] * pFrame->vUp[0] + mRotation[4] * pFrame->vUp[1] + mRotation[8] * pFrame->vUp[2];
vNewVect[1] = mRotation[1] * pFrame->vUp[0] + mRotation[5] * pFrame->vUp[1] + mRotation[9] * pFrame->vUp[2];
vNewVect[2] = mRotation[2] * pFrame->vUp[0] + mRotation[6] * pFrame->vUp[1] + mRotation[10] * pFrame->vUp[2];
memcpy(pFrame->vUp, vNewVect, sizeof(GLfloat) * 3);
}
/////////////////////////////////////////////////////////////

以上代码是一个围绕X轴旋转的函数,其中GLTVector3是OpenGL中定义的类型,相当于C++中的float类型。GLTVector3定义的原型如下:
typedef GLfloat GLTVector3[3]; // Three component floating point vector

位于(\Microsoft Visual Studio\VC98\Include\GL\GLTools.h)GLTools.h代码的51行。

编译错误如下:
E:\OpenGL\Windows\Common\FrameMath.c(178) : error C2275: 'GLTVector3' : illegal use of this type as an expression
D:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\gl\gltools.h(51) : see declaration of 'GLTVector3'
E:\OpenGL\Windows\Common\FrameMath.c(178) : error C2146: syntax error : missing ';' before identifier 'vNewVect'
E:\OpenGL\Windows\Common\FrameMath.c(178) : error C2065: 'vNewVect' : undeclared identifier
E:\OpenGL\Windows\Common\FrameMath.c(180) : error C2109: subscript requires array or pointer type
E:\OpenGL\Windows\Common\FrameMath.c(180) : warning C4244: '=' : conversion from 'float ' to 'int ', possible loss of data
E:\OpenGL\Windows\Common\FrameMath.c(180) : error C2106: '=' : left operand must be l-value

其中错误1:E:\OpenGL\Windows\Common\FrameMath.c(178) : error C2275: 'GLTVector3' : illegal use of this type as an expression
非法使用该类型作为一个表达式。
请问如何解决该问题?????
发表于 2009-11-4 01:38:49 | 显示全部楼层 IP:江苏扬州
不是已经说得很清楚了吗

有没有定义,它是不是一种异常
回复

使用道具 举报

发表于 2009-11-4 01:38:51 | 显示全部楼层 IP:江苏扬州
GLTVector3类型已经在GLTools.h中定义了,它表示一个存储三维坐标的数组。
我作如下定义:
GLTVector3 vNewVect;
编译就出现了这个错误:E:\OpenGL\Windows\Common\FrameMath.c(178) : error C2275: 'GLTVector3' : illegal use of this type as an expression
回复

使用道具 举报

发表于 2009-11-4 01:38:52 | 显示全部楼层 IP:江苏扬州
棘手,在线等。
回复

使用道具 举报

发表于 2009-11-4 01:38:53 | 显示全部楼层 IP:江苏扬州
你好! 我在运行Opengl超级宝典第三版的示例程序时,也遇到这样的问题,不知道你是如何解决的?
回复

使用道具 举报

发表于 2009-11-4 01:38:54 | 显示全部楼层 IP:江苏扬州
me too.
回复

使用道具 举报

发表于 2009-11-4 01:38:56 | 显示全部楼层 IP:江苏扬州
把FrameMath.c文件里所有的GLTVector3 vNewVect;改为全局数组,编译就通过!!!!因为 FrameMath.c文件里有多重定义.
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|小黑屋|最新主题|手机版|微赢网络技术论坛 ( 苏ICP备08020429号 )

GMT+8, 2024-10-1 03:34 , Processed in 0.240625 second(s), 12 queries , Gzip On, MemCache On.

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表