我經常使用#define語句。例如:如何使用#define語句
#include <stdio.h>
#include <stdint.h>
#define SAMPLENO 100
int main()
{
uint8_t num_of_samples;
//some code
if(num_of_samples == SAMPLENO)
{
//some code
}
return 0;
}
最近我聽說#define語句應該和cast類型一起使用。例如:
#include <stdio.h>
#include <stdint.h>
#define SAMPLENO ((uint8_t)100)
int main()
{
uint8_t num_of_samples;
//some code
if(num_of_samples == SAMPLENO)
{
//some code
}
return 0;
}
我的問題是以下,鑄造類型是否必要?
選擇一種語言。沒有C/C++這樣的東西。你不會在C++中爲此使用宏。 – StoryTeller
爲什麼你使用宏? –
你在哪裏頭_「那,#define語句應該與鑄造類型一起使用。」_? –