我在谷歌上搜索过,但我没有找到这个警告的原因Wint-in-bool-context
编译器给了我以下警告:
In file included from /tools/Xilinx/Vivado/2020.1/include/ap_common.h:641,
from /tools/Xilinx/Vivado/2020.1/include/ap_int.h:54,
from src/matrix_mult.h:35,
from src/host.cpp:33:
/tools/Xilinx/Vivado/2020.1/include/etc/ap_private.h: In instantiation of 'void ap_private<_AP_W, _AP_S, true>::clearUnusedBits() volatile [with int _AP_W = 32; bool _AP_S = true]':
/tools/Xilinx/Vivado/2020.1/include/etc/ap_private.h:1485:1: required from 'ap_private<_AP_W, _AP_S, true>& ap_private<_AP_W, _AP_S, true>::operator=(int) [with int _AP_W = 32; bool _AP_S = true]'
/tools/Xilinx/Vivado/2020.1/include/ap_int.h:160:3: required from 'ap_int<_AP_W>::ap_int(int) [with int _AP_W = 32]'
src/host.cpp:50:30: required from here
/tools/Xilinx/Vivado/2020.1/include/etc/ap_private.h:2144:28: warning: enum constant in boolean context [-Wint-in-bool-context]
2144 | : (excess_bits ? (((uint64_t)VAL) << (excess_bits)) >> (excess_bits)
| ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2145 | : (uint64_t)VAL));
这是与此警告相关的代码行(host.cpp 第 50 行):
#include <ap_int.h>; //This is a library for arbitrary precision integers Xilinx HLS
int M,N
static void initialise(ap_int<32> *A)
{
for (int i = 0; i < M; i++) {
for (int j = 0; j < N; j++) {
A[i * N + j] = 1; // _this is line 50_
}
}
}
int main(int argc, char **argv) {
N = atoi(argv[0]); //user input the matrix sizes during run
M = atoi(argv[1]);
std::vector<ap_int<32>,aligned_allocator<ap_int<32>> A(N*M);
initialise(A.data());
目标是创建 32 位整数值向量来存储 N*M 大小的矩阵。