您使用FreeRTOS教程作爲C++的示例。如果你看看FreeRTOS的sources,你會發現它實際上是用C編寫的,而不是C++。
在C語言中引入C風格的單行註釋(//
)之前並不存在於C語言中。很多代碼,包括教程,都是在C99之前編寫的。甚至可以編寫新的C代碼而不使用新的語言功能,以保持程序與不支持新規範的較舊編譯器兼容 - 或僅僅由於舊習慣或偏好。
我一直覺得這是一個有點討厭,因爲它阻止我如果有必要
使用此註釋掉的代碼塊臨時禁用的代碼塊:
#if 0
/* Bits in this RTOS task's notification value are set by the notifying
tasks and interrupts to indicate which events have occurred. */
xTaskNotifyWait(0x00, /* Don't clear any notification bits on entry. */
ULONG_MAX, /* Reset the notification value to 0 on exit. */
&ulNotifiedValue, /* Notified value pass out in
ulNotifiedValue. */
portMAX_DELAY); /* Block indefinitely. */
#endif
對於多行註釋來說,這很容易。使用// vs/* * /僅僅是一種沒有正確技術的樣式選擇 –
很長一段時間'''''''''''* /''是所有可用於便攜式C的類型。因此,舊的C程序員更可能選擇這種形式。請注意,在你的例子中'&ulNotifiedValue'是一個C風格的超參數。 –
不確定爲什麼你標記爲C++? FreeRTOS是用C編寫的。 –