简体   繁体   中英

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

Let's take this code, which is in a header file. The project itself is Objective-C++ (.h &.mm files).

This looks like a mix of C++ and Objective-C. From what I've read, in order to mix Objective-C++ with Objective-C you have to keep all C++ stuff out of the header file, however this is not the case.

The project builds fine, however I cannot replicate this in a new project (by copying the same code).

What settings are needed in Xcode to get this to build? Already compared the project build settings and they're identical.

The errors are related to the inline initializers inside the Options struct.

/*
  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

Some details about the errors as well:

在此处输入图像描述

I assume you are only #include / #import ing this header from .mm files.

The default struct field values are a new feature of C++11. Is the C++ standard in the new project perhaps set to C++98?

I'm not 100% sure on the details, but perhaps some of the more complex default value expressions are only possible in an even newer version of C++. So I suggest you try changing the C++ standard version in the project and see whether it has any effect.

Xcode 中的 C++ 语言方言设置

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM