ошибка: несколько определений символа '$sSo1soiySiSo3stdO3__1O0020___wrap_iter__udAAdDaV_AGtFTO'
ошибка: несколько определения символа '$sSo2eeoiySbSo3stdO3__1O0020___wrap_iter__udAAdDaV_AGtFTO'
ошибка: несколько определений символа '$sSo3stdO3__1O0020___wrap_iter__udAAdDaV9successorAFyF'
ошибка: несколько определений символа '$sSo3st dO3__1O0020___wrap_iter__udAAdDaV2peoiyyAFz_SitFZ'< /p>
Почему?
- swift 5.10
Xcode 15.4
import cppArrayLib
public struct MyArray {
public let doubleValues: [Double]
public let intValues: [UInt32]
public init(arr: ArrayValues) {
self.doubleValues = Array(arr.doubleValues)
self.intValues = Array(arr.intValues)
}
}
Если я изменю инициализатор, чтобы получить доступ к arr только один раз, тогда это сработает:
public init(arr: ArrayValues) {
self.intValues = []
self.doubleValues = Array(arr.doubleValues)
}
cppArrayLib.h
// cppArrayLib.h
#ifndef CPPARRAYLIB_H
#define CPPARRAYLIB_H
#include
typedef struct ArrayValues {
std::vector intValues;
std::vector doubleValues;
} ArrayValues;
#endif
arrayValues.cpp
// cppArray.cpp
#include "cppArrayLib.h"
module.modulemap
module cppArrayLib {
header "cppArrayLib.h"
export *
}
Package.swift
// swift-tools-version: 5.10
import PackageDescription
let package = Package(
name: "CppArray",
products: [
.library(
name: "CppArray",
targets: ["CppArray"]
),
],
targets: [
.target(
name: "cppArrayLib",
dependencies: []
),
.target(
name: "CppArray",
dependencies: ["cppArrayLib"],
swiftSettings: [.interoperabilityMode(.Cxx)]
),
.testTarget(
name: "CppArrayTests",
dependencies: ["CppArray"]
),
],
cxxLanguageStandard: .cxx20
)
Структура упаковки
Sources
|
+-CppArrayLib
| |
| +-include
| | |
| | +-cppArrayLib.hpp
| | +-module.modulemap
| |
| +-arrayValues.cpp
|
+-CppArray
| |
| +-CppArray.swift
Подробнее здесь: https://stackoverflow.com/questions/791 ... t-in-swift
Мобильная версия