【发布时间】:2020-07-01 12:58:09
【问题描述】:
我正在尝试在 C++ 中使用 SCHED_DEADLINE,我需要将 struct sched_attr 发送到 ioctl,所以我包含了 <linux/sched/types.h>,该标题也恰好包含 strut sched_param。我还包括<string>,其中包括c++ 的标准头文件,最终包括include\bits\sched.h,它还定义了struct sched_param。编译器(显然)并不特别喜欢这个。我在代码中使用了标头保护 (_BITS_TYPES_STRUCT_SCHED_PARAM) 让编译器不包含 include\bits\sched.h,但感觉应该有一个“更好”的方法。
> Executing task in folder sched_deadline_testing: arm-linux-gnueabihf-g++ -o LSM9DS0 src/LSM9DS0.cpp -Wall --pedantic <
In file included from src/LSM9DS0.cpp:36:
/usr/arm-linux-gnueabihf/include/linux/sched/types.h:7:8: error: redefinition of ‘struct sched_param’
struct sched_param {
^~~~~~~~~~~
In file included from /usr/arm-linux-gnueabihf/include/bits/sched.h:74,
from /usr/arm-linux-gnueabihf/include/sched.h:43,
from /usr/arm-linux-gnueabihf/include/pthread.h:23,
from /usr/arm-linux-gnueabihf/include/c++/8/arm-linux-gnueabihf/bits/gthr-default.h:35,
from /usr/arm-linux-gnueabihf/include/c++/8/arm-linux-gnueabihf/bits/gthr.h:148,
from /usr/arm-linux-gnueabihf/include/c++/8/ext/atomicity.h:35,
from /usr/arm-linux-gnueabihf/include/c++/8/bits/basic_string.h:39,
from /usr/arm-linux-gnueabihf/include/c++/8/string:52,
from src/LSM9DS0.cpp:20:
/usr/arm-linux-gnueabihf/include/bits/types/struct_sched_param.h:23:8: note: previous definition of ‘struct sched_param’
struct sched_param
代码是here,如果这很重要的话。我也尝试过这种交叉编译和本地编译,两者都会导致问题。
【问题讨论】: