gpt4 book ai didi

function - 在 void 上下文中使用非 void 函数?

转载 作者:行者123 更新时间:2023-12-02 07:42:27 25 4
gpt4 key购买 nike

我正在使用 SystemVerilog。我的代码是:

function write_pixel_data(datastr ds);
/* some stuff here... but no return */
endfunction

然后我这样调用我的函数:

write_pixel_data(someval);

然后我收到 vcs 警告:

Warning-[SV-NFIVC] Non-void function used in void context.

但我没有返回任何东西,我知道我可以将函数调用强制转换为 void 以消除警告。但是为什么会给出这个警告??!!

谢谢。

最佳答案

如果您没有将该函数声明为 void 并且您调用它时没有将返回值分配给任何东西,您将看到此错误。简单修复:

function void write_pixel_data(datastr ds);
/* some stuff here... but no return */
endfunction

不过要小心,您不能在函数中做任何“需要时间”的事情。为此,您需要一个任务

关于function - 在 void 上下文中使用非 void 函数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9686840/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com