我经常使用#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语句应该与铸造类型一起使用。”_? –