取消对句柄的指针引用会给我"illegal, right operand.."?
Derefering a pointer to a handle is giving me "illegal, right operand.."?
我不明白编译器试图强制执行什么。我有一个函数可以设置 OpenGL 上下文,并通过指针返回HGLRC
:
BOOL SetupWin32Context(HDC hDC, HGLRC *phRC) {
/* do bunch of work*/
HGLRC hRC = wglCreateContext(hDC);
*phRC = hRC;
return TRUE;}
在*phRC = hRC;
我得到:
error C2297: '*' : illegal, right operand has type 'HGLRC *'
这对我来说没有任何意义。
从粘贴复制的完整代码
#include "Bindings.h"
#include <Windows.h>
#include <glGL.h>
BOOL SetupWin32Context(HDC hDC, HGLRC *phRC)
{
HGLRC hRC = NULL;
PIXELFORMATDESCRIPTOR pfd =
{
sizeof(PIXELFORMATDESCRIPTOR),
1,
PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER,
PFD_TYPE_RGBA,
32, /* Colordepth of the framebuffer. */
0, 0, 0, 0, 0, 0,
0,
0,
0,
0, 0, 0, 0,
0, /* Bits of the depthbuffer. */
0, /* Bits of the stencilbuffer. */
0, /* Number of Aux buffers. */
PFD_MAIN_PLANE,
0,
0, 0, 0
};
int format = ChoosePixelFormat(hDC, &pfd);
if(format == 0) return FALSE;
if(!SetPixelFormat(hDC,format, &pfd)) return FALSE;
hRC = wglCreateContext(hDC);
if(hRC == 0)
hRC = wglCreateContext(hDC);
if(hRC == 0)
return FALSE;
wglMakeCurrent(hDC, hRC)
*phRC = hRC;
return TRUE;
}
在实际代码中,您需要在后面使用分号
wglMakeCurrent(hDC, hRC)
喜欢这个:
wglMakeCurrent(hDC, hRC);
相关文章:
- 为什么使用 QString::right 在字符串开头省略逗号?
- 键入擦除成员函数指针的"right"方法是什么?
- 如何解决g++问题"internal compiler error: Illegal instruction min() _GLIBCXX_USE_NOEXCEPT { return __FLT_MI
- Problems with QByteArray::right
- 用于"Ctrl + left arrow"和"Ctrl + right arrow"的八进制代码
- "The order of evaluation of expressions is left to right."是什么意思
- 在表达式 left() = right() 中,为什么首先对 right() 进行排序
- (C++)在按位 OR 操作时获取错误"Illegal instruction (core dumped)"
- 检查数组是否'right' (C++)
- 当我做出语句 root->right->right = newnode(7);注释,编译器显示运行时错误。谁能解释为什么?
- ODBC 错误"String data, right truncation State code: 22001"与 SQL Server 数据库
- GL_INVALID_ENUM right after context initialization
- C++ Illegal else
- C 中的Right-Align GetLine()输入
- Iomanip errors with std::left/right
- 使用指针时遇到错误"The NTVDM CPU has encountered an illegal instruction"
- 库达库兰德"An illegal memory access was encountered"
- 以"right"的方式进行QThreading
- 在 Mac 10.9 上从 Android 源代码构建 aapt 小牛队在 10.8 山狮上出现段错误或给出"Illegal Instruction 4"
- 取消对句柄的指针引用会给我"illegal, right operand.."?