预期的asm或__attribute__在CRenderContext之前 [英] expected asm or __attribute__ before CRenderContext
问题描述
我在Linux下使用CodeBlocks IDE开发一个小应用程序。
我使用下面的代码定义了一个类:
I am developing a small app under Linux using the CodeBlocks IDE. I have defined a class with the following code:
class CRenderContext
{
public: /*instance methods*/
CRenderContext() :
m_iWidth(0), m_iHeight(0),
m_iX(0), m_iY(0),
m_bFullScreen(false), m_bShowPointer(false) {};
CRenderContext (int iWidth,
int iHeight,
int iX,
int iY,
bool bFullScreen,
bool bShowPointer)
:
m_iWidth(iWidth), m_iHeight(iHeight),
m_iX(iX), m_iY(iY),
m_bFullScreen(bFullScreen), m_bShowPointer(bShowPointer) {};
virtual ~CRenderContext () {};
public: /*instance data*/
int m_iWidth;
int m_iHeight;
int m_iX;
int m_iY;
bool m_bFullScreen;
bool m_bShowPointer;
};
在编译上述代码时,总是出现以下错误:
I always get the following error when compiling the above code:
错误:expected'=',',',';','asm'或'attribute'
error: expected '=', ',', ';', 'asm' or 'attribute' before CRenderContext
解决错误?
先感谢,
Eugenio
推荐答案
您正在将其编译为C代码,而不是C ++。您可能需要将源文件重命名为具有.cpp扩展名。代码编译完全(作为C ++)与g ++和gotau,虽然你有一些多余的分号。例如:
You are compiling it as C code, not C++. You probably need to rename the source file to have a .cpp extension. The code compiles perfectly (as C++) with g++ and comeau, although you have some superfluous semicolons. For example:
virtual ~CRenderContext () {};
不需要分号结束。
这篇关于预期的asm或__attribute__在CRenderContext之前的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!