取消对句柄的指针引用会给我"illegal, right operand.."?

Derefering a pointer to a handle is giving me "illegal, right operand.."?

本文关键字:illegal right operand 句柄 指针 引用 取消      更新时间:2023-10-16

我不明白编译器试图强制执行什么。我有一个函数可以设置 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);