Xcode 中需要什么设置才能构建此代码

What settings are needed in Xcode to get this code to build

让我们来看看这个位于头文件中的代码。项目本身是 Objective-C++(.h & .mm 文件)。

这看起来像是 C++ 和 Objective-C 的混合体。根据我的阅读,为了将 Objective-C++ 与 Objective-C 混合,您必须将所有 C++ 内容保留在头文件之外,但事实并非如此。

项目构建良好,但我无法在新项目中复制它(通过复制相同的代码)。

Xcode 需要什么设置才能构建?已经比较了项目构建设置,它们是相同的。

错误与 Options 结构内的内联初始化程序有关。

/*
  This file is part of the Structure SDK.
  Copyright © 2019 Occipital, Inc. All rights reserved.
  http://structure.io
*/

#import <UIKit/UIKit.h>
#import <AVFoundation/AVFoundation.h>

#import <Structure/Structure.h>
#import <Structure/STCaptureSession.h>

#import "CalibrationOverlay.h"
#import "MeshViewController.h"
#import "SettingsPopupView.h"

// See default initialization in: -(void)initializeDynamicOptions
struct DynamicOptions
{
    bool depthAndColorTrackerIsOn;
    bool improvedTrackingIsOn;
    bool highResColoring;
    bool improvedMapperIsOn;
    bool highResMapping;
    STCaptureSessionPreset depthStreamPreset;
};

struct Options
{
    // The initial scanning volume size will be 0.5 x 0.5 x 0.5 meters
    // (X is left-right, Y is up-down, Z is forward-back)
    const GLKVector3 initVolumeSizeInMeters = GLKVector3Make (0.5f, 0.5f, 0.5f);
    
    // The maximum number of keyframes saved in keyFrameManager
    int maxNumKeyFrames = 48;
    
    // Colorizer quality
    STColorizerQuality colorizerQuality = STColorizerHighQuality;
    
    // Take a new keyframe in the rotation difference is higher than 20 degrees.
    float maxKeyFrameRotation = 20.0f * (M_PI / 180.f); // 20 degrees
    
    // Take a new keyframe if the translation difference is higher than 30 cm.
    float maxKeyFrameTranslation = 0.3; // 30cm

    // Threshold to consider that the rotation motion was small enough for a frame to be accepted
    // as a keyframe. This avoids capturing keyframes with strong motion blur / rolling shutter.
    float maxKeyframeRotationSpeedInDegreesPerSecond = 1.f;
    
    // Whether we should use depth aligned to the color viewpoint when Structure Sensor was calibrated.
    // This setting may get overwritten to false if no color camera can be used.
    bool useHardwareRegisteredDepth = false;
    
    // Whether to enable an expensive per-frame depth accuracy refinement.
    // Note: this option requires useHardwareRegisteredDepth to be set to false.
    const bool applyExpensiveCorrectionToDepth = true;
    
    // Whether the colorizer should try harder to preserve appearance of the first keyframe.
    // Recommended for face scans.
    bool prioritizeFirstFrameColor = true;
    
    // Target number of faces of the final textured mesh.
    int colorizerTargetNumFaces = 50000;
    
    // Focus position for the color camera (between 0 and 1). Must remain fixed one depth streaming
    // has started when using hardware registered depth.
    const float lensPosition = 0.75f;
};

...
@interface ViewController : UIViewController <STBackgroundTaskDelegate, MeshViewDelegate, AVCaptureVideoDataOutputSampleBufferDelegate, UIPopoverControllerDelegate, UIGestureRecognizerDelegate, SettingsPopupViewDelegate>
{
...
}
@end

关于错误的一些详细信息:

我假设您只是 #include/#import.mm 个文件中编辑此 header。

默认结构字段值是 C++11 的新功能。新项目中的C++标准是否可能设置为C++98?

我不是 100% 确定细节,但也许一些更复杂的默认值表达式只能在更新版本的 C++ 中使用。所以我建议你在项目中尝试更改C++标准版本,看看是否有效果。