2011-04-09 87 views
0

試圖在xcode中編譯unity3d項目,但我在下面的函數中得到以下編譯錯誤。有人知道原因是什麼?函數聲明器之後的預期函數體

使用的Xcode 4,SDK 4.3和Unity 3.3 基地SDK被設定爲4.3,在Unity SDK版本之前設置爲4.2和目標的iOS至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 
    } 

的代碼於上述功能如下:

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]; 
} 
+0

沒有「」令牌(第一個錯誤)在你發佈的代碼片段中,這表明這是一個後續錯誤,問題在你引用的代碼之前。 – CRD 2011-04-09 20:00:55

+0

我修改了代碼,但#if語句破壞了佈局。 – Zophiel 2011-04-09 22:11:54

+0

@Zophiel。請修正您的代碼格式。 「#if」語句「破壞」佈局的原因是它們沒有完全縮進。請參閱http://daringfireball.net/projects/markdown/syntax#precode以獲得進一步參考。 – 2011-04-09 22:16:31

回答

0

Oke發現問題在於Unity 3.3內在的問題。如何過,這是easilly從「4.2」進入的是iOS播放器設置,調整值的tagrt SDK來「因爲4.2最新的」

0

我剛剛刪除的&那是在變量前面固定。 ..現在我可以球泡

0

添加下面兩行我Prefix.pch

#define __IPHONE_OS_VERSION_MAX_ALLOWED __IPHONE_4_2 
#define __IPHONE_OS_VERSION_MIN_REQUIRED __IPHONE_3_0