函数声明符之后的预期函数体

发布于 2024-10-31 21:52:53 字数 4282 浏览 1 评论 0原文

尝试在 xcode 中编译 unity3d 项目,但我在下面的函数中遇到以下编译错误。有谁知道是什么原因吗?

使用 Xcode 4、SDK 4.3 和 Unity 3.3 基础 SDK 设置为 4.3,Unity 中的 SDK 版本设置为 4.2,目标 iOS 设置为 3.2

AppController.mm:710: 错误:预期 '.' 之前的初始化程序令牌

AppController.mm:错误:解析问题:函数声明符后面需要函数体

   void PresentContext_UnityCallback(struct UnityFrameStats const* unityFrameStats)
    {   
    #if ENABLE_INTERNAL_PROFILER
        _unityFrameStats = *unityFrameStats;

        if (_frameId % BLOCK_ON_GPU_EACH_NTH_FRAME == (BLOCK_ON_GPU_EACH_NTH_FRAME-1))
        {
            Prof_Int64 gpuTime0 = mach_absolute_time();

    #if ENABLE_BLOCK_ON_GPU_PROFILER
            UnityFinishRendering();
    #endif

            Prof_Int64 gpuTime1 = mach_absolute_time();
            _gpuDelta = gpuTime1 - gpuTime0;
        }
        else
            _gpuDelta = 0;
    #endif


    #if ENABLE_INTERNAL_PROFILER
        Prof_Int64 swapTime0 = mach_absolute_time();
    #endif

        PresentSurface(_surface);

    #if ENABLE_INTERNAL_PROFILER
        Prof_Int64 vblankTime = mach_absolute_time();

        if (_lastVBlankTime < 0) _lastVBlankTime = vblankTime;
        _frameDelta = vblankTime - _lastVBlankTime; _lastVBlankTime = vblankTime;

        Prof_Int64 swapTime1 = vblankTime;
        _swapDelta = swapTime1 - swapTime0;
    #endif
    }

上述函数之前的代码如下:

void PresentSurface(MyEAGLSurface& surface)
{
    UNITY_DBG_LOG ("PresentSurface:\n");
    EAGLContext *oldContext = [EAGLContext currentContext];

    if (oldContext != _context)
        [EAGLContext setCurrentContext:_context];

#if GL_APPLE_framebuffer_multisample
    if (surface.msaaSamples > 0 && _supportsMSAA)
    {
        UnityStartProfilerCounter(msaaResolveCounter);
        #if ENABLE_INTERNAL_PROFILER
        Prof_Int64 msaaTime0 = mach_absolute_time();
        #endif

        UNITY_DBG_LOG ("  ResolveMSAA: samples=%i msaaFBO=%i destFBO=%i\n", surface.msaaSamples, surface.msaaFramebuffer, surface.framebuffer);
        glBindFramebufferOES(GL_READ_FRAMEBUFFER_APPLE, surface.msaaFramebuffer); 
        glBindFramebufferOES(GL_DRAW_FRAMEBUFFER_APPLE, surface.framebuffer);

        glResolveMultisampleFramebufferAPPLE();
        CHECK_GL_ERROR();

        #if ENABLE_INTERNAL_PROFILER
        _msaaResolve += (mach_absolute_time() - msaaTime0);
        #endif
        UnityEndProfilerCounter(msaaResolveCounter);
    }
#endif

#if GL_EXT_discard_framebuffer
    if (_supportsDiscard)
    {
        GLenum attachments[3];
        int discardCount = 0;
        if (surface.msaaSamples > 1 && _supportsMSAA)
            attachments[discardCount++] = GL_COLOR_ATTACHMENT0_OES;

        if (surface.depthFormat)
            attachments[discardCount++] = GL_DEPTH_ATTACHMENT_OES;

        attachments[discardCount++] = GL_STENCIL_ATTACHMENT_OES;

        GLenum target = (surface.msaaSamples > 1 && _supportsMSAA)? GL_READ_FRAMEBUFFER_APPLE: GL_FRAMEBUFFER_OES;
        if (discardCount > 0)
            glDiscardFramebufferEXT(target, discardCount, attachments);
    }
#endif

    CHECK_GL_ERROR();

    // presentRenderbuffer presents currently bound RB, so make sure we have the correct one bound
    glBindRenderbufferOES(GL_RENDERBUFFER_OES, surface.renderbuffer);   
    if(![_context presentRenderbuffer:GL_RENDERBUFFER_OES])
        EAGL_ERROR("swap renderbuffer");

#if GL_APPLE_framebuffer_multisample
    if (_supportsMSAA)
    {
        const int desiredMSAASamples = UnityGetDesiredMSAASampleCount(MSAA_DEFAULT_SAMPLE_COUNT);   
        if (surface.msaaSamples != desiredMSAASamples)
        {
            surface.msaaSamples = desiredMSAASamples;
            CreateSurfaceMultisampleBuffers(&surface);
            glBindRenderbufferOES(GL_RENDERBUFFER_OES, surface.renderbuffer);
        }

        if (surface.msaaSamples > 1)
        {
            glBindFramebufferOES(GL_FRAMEBUFFER_OES, surface.msaaFramebuffer);
            gDefaultFBO = surface.msaaFramebuffer;
            UNITY_DBG_LOG ("  glBindFramebufferOES (GL_FRAMEBUFFER_OES, %i); // PresentSurface\n", surface.msaaFramebuffer);
        }
    }
#endif

    if(oldContext != _context)
        [EAGLContext setCurrentContext:oldContext];
}

Trying to compile a unity3d project in xcode but i'm getting the following compile errors on the function below. Anybody know what the cause is?

Using Xcode 4, SDK 4.3 and Unity 3.3
Base SDK is set to 4.3, SDK version in Unity is set to 4.2 and target iOS to 3.2

AppController.mm:710: error: expected
initializer before '.' token

AppController.mm: error: Parse Issue: Expected function body after function declarator

   void PresentContext_UnityCallback(struct UnityFrameStats const* unityFrameStats)
    {   
    #if ENABLE_INTERNAL_PROFILER
        _unityFrameStats = *unityFrameStats;

        if (_frameId % BLOCK_ON_GPU_EACH_NTH_FRAME == (BLOCK_ON_GPU_EACH_NTH_FRAME-1))
        {
            Prof_Int64 gpuTime0 = mach_absolute_time();

    #if ENABLE_BLOCK_ON_GPU_PROFILER
            UnityFinishRendering();
    #endif

            Prof_Int64 gpuTime1 = mach_absolute_time();
            _gpuDelta = gpuTime1 - gpuTime0;
        }
        else
            _gpuDelta = 0;
    #endif


    #if ENABLE_INTERNAL_PROFILER
        Prof_Int64 swapTime0 = mach_absolute_time();
    #endif

        PresentSurface(_surface);

    #if ENABLE_INTERNAL_PROFILER
        Prof_Int64 vblankTime = mach_absolute_time();

        if (_lastVBlankTime < 0) _lastVBlankTime = vblankTime;
        _frameDelta = vblankTime - _lastVBlankTime; _lastVBlankTime = vblankTime;

        Prof_Int64 swapTime1 = vblankTime;
        _swapDelta = swapTime1 - swapTime0;
    #endif
    }

The code prior to the above function is as follows:

void PresentSurface(MyEAGLSurface& surface)
{
    UNITY_DBG_LOG ("PresentSurface:\n");
    EAGLContext *oldContext = [EAGLContext currentContext];

    if (oldContext != _context)
        [EAGLContext setCurrentContext:_context];

#if GL_APPLE_framebuffer_multisample
    if (surface.msaaSamples > 0 && _supportsMSAA)
    {
        UnityStartProfilerCounter(msaaResolveCounter);
        #if ENABLE_INTERNAL_PROFILER
        Prof_Int64 msaaTime0 = mach_absolute_time();
        #endif

        UNITY_DBG_LOG ("  ResolveMSAA: samples=%i msaaFBO=%i destFBO=%i\n", surface.msaaSamples, surface.msaaFramebuffer, surface.framebuffer);
        glBindFramebufferOES(GL_READ_FRAMEBUFFER_APPLE, surface.msaaFramebuffer); 
        glBindFramebufferOES(GL_DRAW_FRAMEBUFFER_APPLE, surface.framebuffer);

        glResolveMultisampleFramebufferAPPLE();
        CHECK_GL_ERROR();

        #if ENABLE_INTERNAL_PROFILER
        _msaaResolve += (mach_absolute_time() - msaaTime0);
        #endif
        UnityEndProfilerCounter(msaaResolveCounter);
    }
#endif

#if GL_EXT_discard_framebuffer
    if (_supportsDiscard)
    {
        GLenum attachments[3];
        int discardCount = 0;
        if (surface.msaaSamples > 1 && _supportsMSAA)
            attachments[discardCount++] = GL_COLOR_ATTACHMENT0_OES;

        if (surface.depthFormat)
            attachments[discardCount++] = GL_DEPTH_ATTACHMENT_OES;

        attachments[discardCount++] = GL_STENCIL_ATTACHMENT_OES;

        GLenum target = (surface.msaaSamples > 1 && _supportsMSAA)? GL_READ_FRAMEBUFFER_APPLE: GL_FRAMEBUFFER_OES;
        if (discardCount > 0)
            glDiscardFramebufferEXT(target, discardCount, attachments);
    }
#endif

    CHECK_GL_ERROR();

    // presentRenderbuffer presents currently bound RB, so make sure we have the correct one bound
    glBindRenderbufferOES(GL_RENDERBUFFER_OES, surface.renderbuffer);   
    if(![_context presentRenderbuffer:GL_RENDERBUFFER_OES])
        EAGL_ERROR("swap renderbuffer");

#if GL_APPLE_framebuffer_multisample
    if (_supportsMSAA)
    {
        const int desiredMSAASamples = UnityGetDesiredMSAASampleCount(MSAA_DEFAULT_SAMPLE_COUNT);   
        if (surface.msaaSamples != desiredMSAASamples)
        {
            surface.msaaSamples = desiredMSAASamples;
            CreateSurfaceMultisampleBuffers(&surface);
            glBindRenderbufferOES(GL_RENDERBUFFER_OES, surface.renderbuffer);
        }

        if (surface.msaaSamples > 1)
        {
            glBindFramebufferOES(GL_FRAMEBUFFER_OES, surface.msaaFramebuffer);
            gDefaultFBO = surface.msaaFramebuffer;
            UNITY_DBG_LOG ("  glBindFramebufferOES (GL_FRAMEBUFFER_OES, %i); // PresentSurface\n", surface.msaaFramebuffer);
        }
    }
#endif

    if(oldContext != _context)
        [EAGLContext setCurrentContext:oldContext];
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

苏辞 2024-11-07 21:52:53

事实证明,问题本质上出在 Unity 3.3 中。然而,通过进入 iOS 的播放器设置并将 tagrt SDK 的值从“4.2”重新调整为“自 4.2 以来的最新版本”,可以轻松解决此问题

Oke turns out the problem lies inherently within Unity 3.3. How ever, this is easilly fixed by going into the player settings for iOS and readjusting the value for the tagrt SDK from "4.2" to "latest since 4.2"

贪恋 2024-11-07 21:52:53

我刚刚删除了 &那是在变量前面......现在我可以

I just deleted the & that was in front of the variable ... Now I can buld

佞臣 2024-11-07 21:52:53

将以下两行添加到我的 Prefix.pch 中

#define __IPHONE_OS_VERSION_MAX_ALLOWED   __IPHONE_4_2
#define __IPHONE_OS_VERSION_MIN_REQUIRED  __IPHONE_3_0

Add following two lines to my Prefix.pch

#define __IPHONE_OS_VERSION_MAX_ALLOWED   __IPHONE_4_2
#define __IPHONE_OS_VERSION_MIN_REQUIRED  __IPHONE_3_0
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文