0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

FIT SDKのC++の静的ライブラリをビルドする

Last updated at Posted at 2021-01-04

概要

Fit SDK 21.40(c++)には、DeveloperField使用時にクラッシュするバグがある。
Fit SDK 21.47で修正されました。

これを回避するために、c++のソースコードを修正して静的ライブラリをビルドする。

環境

FitSDKのソースコード修正

i386アーキテクチャを削除(Xcode12でビルドエラーになるため)

$ cd cpp/MacStaticLib/
$ find . \( -name "*.xcconfig" -o -name "*.pbxproj" \) | xargs sed -i '' -e 's/-arch i386//g' -e 's/i386//g'
cpp/MacStaticLib/build.py
    # Compile the project
    # subprocess.call([XCODEBUILDER, XCODEPROJECT, project, XCODETARGET, p[TARGET]])
    subprocess.call([XCODEBUILDER, "-UseModernBuildSystem=NO", XCODEPROJECT, project, XCODETARGET, p[TARGET]])
cpp/fit_developer_field_definition.hpp
    FIT_BOOL operator!=(const DeveloperFieldDefinition& field) const;
    // ↓ Added
    DeveloperFieldDefinition& operator=(const DeveloperFieldDefinition& other);
cpp/fit_developer_field_definition.cpp
FIT_BOOL DeveloperFieldDefinition::operator!=(const DeveloperFieldDefinition& field) const
{
    return !(*this == field);
}

// ↓ Added
DeveloperFieldDefinition& DeveloperFieldDefinition::operator=(const DeveloperFieldDefinition& other) 
{
    if (this != &other){
        num = other.num;
        size = other.size;
        developerDataIndex = other.developerDataIndex;
        if (mesg != nullptr){
            delete mesg;
            mesg = nullptr;
        }

        if (other.mesg != nullptr) {
            mesg = new FieldDescriptionMesg(*other.mesg);
        }
        
        if (developer != nullptr){
            delete developer;
            developer = nullptr;
        }

        if (other.developer != nullptr){
            developer = new DeveloperDataIdMesg( *other.developer );
        }
    }
    return *this;
}

Build static lib

$ cd cpp/MacStaticLib
$ python build.py
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?