This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[参考译文] CCS/TM4C1290NCPDT:构建后、我是否应该将 Semaphore_Params 和 GateMutexPri_Params 保留在示波器中?

Guru**** 3040470 points
请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/tools/code-composer-studio-group/ccs/f/code-composer-studio-forum/864911/ccs-tm4c1290ncpdt-should-i-keep-semaphore_params-and-gatemutexpri_params-in-scope-after-construction

器件型号:TM4C1290NCPDT

工具/软件:Code Composer Studio

标题说明了一切:在我构建/创建一个锁定对象(信标或门)之后、我是否必须将_Params 对象保留在作用域中? 还是将_Params 对象中的数据复制到 lock 对象? 以下是一个我的意思示例:

```μ A

Semaphore_Handle ConstructBinaryPrioritySemaphore (Semaphore_Struct&SEM)
{
Semaphore_Params 参数;
Semaphore_Params_init (&params);
params.mode = Semaphore_Mode_binary_priority;

Semaphore_construction (&sem、0、&params);
返回 Semaphore_handle (&sem);

}

```μ A

上面的代码是否正确、或者在函数末尾被销毁的参数是否会导致问题?

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    尊敬的 Franco:

    代码正常。 创建(和构造)会将需要保留的任何内容从参数结构复制到对象结构中。  

    注意:如果在上述函数中将缓冲区用作局部变量并将其用于实例的名称(您在上面未进行设置)、则这将是一个问题、因为构造会将名称的地址复制到对象中。  

    Todd