我们正在 Kotlin 中创建一个多平台项目,并且某个模块的一部分使用了实验性协程功能。
我们正在使用 Gradle 一起构建项目/库。通用模块的 gradle 构建脚本如下所示:
apply plugin: 'kotlin-platform-common'
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-common:$kotlin_version"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:0.22.5"
testCompile "org.jetbrains.kotlin:kotlin-test-annotations-common:$kotlin_version"
testCompile "org.jetbrains.kotlin:kotlin-test-common:$kotlin_version"
}
kotlin {
experimental {
coroutines "enable"
}
}
Run Code Online (Sandbox Code Playgroud)
这里真的没什么特别的。然而,协程所依赖的 Kotlin 标准库版本与我们想要在项目中使用的 Kotlin 标准库版本冲突似乎存在问题。
除了其他信息外,gradle module:dependencies输出一棵树,其中包含以下信息:
compileClasspath - Compile classpath for source set 'main'.
+--- org.jetbrains.kotlin:kotlin-stdlib-common:1.2.41
\--- org.jetbrains.kotlinx:kotlinx-coroutines-core:0.22.5
\--- org.jetbrains.kotlin:kotlin-stdlib:1.2.21
\--- org.jetbrains:annotations:13.0
compileOnly - Compile only dependencies for source set 'main'.
No dependencies
default - Configuration for default artifacts.
+--- org.jetbrains.kotlin:kotlin-stdlib-common:1.2.41
\--- org.jetbrains.kotlinx:kotlinx-coroutines-core:0.22.5
\--- org.jetbrains.kotlin:kotlin-stdlib:1.2.21 …Run Code Online (Sandbox Code Playgroud) 我正在尝试调试用于验证用户输入的递归函数,并在输入正常时返回一个值.该函数如下所示:
double load_price()
{
double price;
Goods * tempGd = new Goods();
cin >> price;
while (!cin)
{
cin.clear();
#undef max
std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
cout << endl;
cout << "You didn't enter a number. Do so, please: ";
cin >> price;
} // endwhile
if (!tempGd->set_price(price))
{
cout << endl;
cout << "The price " << red << "must not" << white << " be negative." << endl;
cout << "Please, insert a new price: ";
load_price();
}
else
{
delete …Run Code Online (Sandbox Code Playgroud)