在构建导入的项目时,会发生错误。我正在使用gcc版本9。
我已经成功构建了Inet 4.1。我也尝试使用5到8之间的其他gcc版本进行此操作,但是发生了相同的错误。
main.cc
In file included from /usr/include/c++/9/bits/stl_algo.h:66,
from /usr/include/c++/9/algorithm:62,
from /home/sebastian/Downloads/omnetpp-5.4.1/include/omnetpp.h:29,
from main.cc:20:
/usr/include/c++/9/bits/uniform_int_dist.h: In instantiation of ‘class std::uniform_int_distribution<double>’:
model/Showcase/Layer1/DummyWindPark/WindPowerGenerator.h:53:43: required from here
/usr/include/c++/9/bits/uniform_int_dist.h:60:49: error: static assertion failed: template argument must be an integral type
60 | static_assert(std::is_integral<_IntType>::value,
| ^~~~~
In file included from model/Showcase/Layer1/Windpark/WindParkNetwork.h:21,
from model/Showcase/Layer1/SmartParkingScenario.h:26,
from main.cc:26:
答案 0 :(得分:0)
您,或者是写头文件model/Showcase/Layer1/DummyWindPark/WindPowerGenerator.h
的人,
正在尝试在该文件中实例化模板template< class IntType = int >class uniform_int_distribution
编译器指出,IntType
= double
In instantiation of ‘class std::uniform_int_distribution<double>’
double
不是整数类型,并且模板包含static_assert
要求IntType
是整数类型。这样static_assert
的编译时间就会失败:
error: static assertion failed: template argument must be an integral type
整数类型是满足模板谓词std::is_integral
的那些类型。
如果您或失败的std::uniform_int_distribution<double>
的作者希望生成
double
的均匀分布,那么他们应该使用template< class RealType = double > class uniform_real_distribution