当前位置: 首页 > news >正文

广东网站开发项目专业搜索引擎seo服务

广东网站开发项目,专业搜索引擎seo服务,苏州外贸网站建设公司,网站验证钱的分录怎么做文章目录 宏定义无参宏定义带参宏定义固定参数宏可变参数宏 多语句宏处理连接符条件判断常见预定义宏 宏在C语言中是一段有名称的代码片段(使用#define定义),在预处理阶段会把程序中的宏名替换为对应的代码片段,然后才进入编译阶段…

文章目录

  • 宏定义
    • 无参宏定义
    • 带参宏定义
    • 固定参数宏
    • 可变参数宏
  • 多语句宏处理
  • 连接符
  • 条件判断
  • 常见预定义宏

宏在C语言中是一段有名称的代码片段(使用#define定义),在预处理阶段会把程序中的宏名替换为对应的代码片段,然后才进入编译阶段由编译器进行编译。

  • #define:宏定义
  • #undef:取消宏定义
  • #ifdef:判断宏是否定义

宏定义

无参宏定义

最简单的宏定义时间用指定的标识符来代表代码片段,当宏定义有多行时,需要在行尾使用\来连接。

#define 宏名称  代码片段// 如(多行时,行尾使用\作为续行符)
#define BUFFER_SIZE 1024
#define RANDOM (2.0*(double)rand() / RAND_MAX)
#define NUMBERS 1, \2, \3int x[] = { NUMBERS };

带参宏定义

类似函数定义,宏名称后紧跟括号(名称与括号间不能有空格)。

固定参数宏

“形参列表”是用逗号隔开的多个标识符(也可以空,表示无参数),实参列表中的实参数量必须与宏定义中的形参数量一样多。

#define 宏名称( [形参列表] )  替换文本
// 如
#define GETCHAR() getc(stdin)
#define MAX(a,b) ((a)>(b)?(a):(b))
//参数要用括号括起,避免实参为表达式时出错,如
#define MULTIPLY(a, b) ((a)*(b))
//MULTIPLY(1+2, 3+4)会预处理为((1+2)*(3+4)),若不加括号,则会变为1+2*3+4(意义全变)。

即使加括号,宏在一定情况下还是会产生二义性(要避免此类使用),如

#define SQUARE(a) ((a)*(a))

SQUARE(a++)会预处理为((a++)(a++))(若a=3,则结果为34)。

可变参数宏

C99标准允许定义有省略号的宏(在替换文本中使用__VA_ARGS__标识可变参数),省略号必须放在参数列表的最后面表示可变参数。

#define OUTLOG(fmt, ...) printf(__func__, fmt, __VA_ARGS__)

多语句宏处理

对于有多条语句的复杂宏,为避免错误,需要使用do{}while(0)包含(避免出现多余分号等的报错)。

#define SAFE_DELETE(ptr)  \do{ \if(NULL != ptr){  \delete ptr;     \ptr=NULL;       \} \}while(0)

连接符

在宏体中,通过在参数前面加不同符号,会有不同的扩展:

  • #:参数扩展为字符串形式
  • ##:连接符,把两部分连接为一个标识符
  • #@:参数扩展为字符
    通过这些连接符,可以实现一些复杂的操作(如MFC中自动生成类等):
#define CHAR_VAR(n, c)  char var##n = #@c
#define ARRAY_VAR(n, str)  char ary##n[] = #str// char vara='a';
CHAR_VAR(a, a);
// char arya[]="abc";
ARRAY_VAR(a, abc);

条件判断

条件编译里面有判断语句,如 #if 、#else 、#elif 及 #endif。类似if语句,在里面可以使用与、或、非及比较表达式。通过条件判断可以使代码适应不同的运行环境(针对不同环境,编译不同代码部分)。

//#ifdef 是 '#if defined'的简写
#if defined(X_OS_WIN32) || defined(X_OS_WIN64) 
// Windows代码处理...
#endif

VC中判断当前是否为Debug:

#ifdef _DEBUG
#pragma comment(lib, "my-debug.lib")
#else
#pragma comment(lib, "my-release.lib")
#endif

C++中定义标准C接口(使用extern “C”)

#ifdef __cplusplus
extern "C"{
#endif// ... 代码#ifdef __cplusplus
}
#endif
在判断是否满足指定要求#if defined(MY_TEST_VER) && (MY_TEST_VER>=2)
// ...
#endif

常见预定义宏

预定义宏:

__DATE__: 字符串, 进行预处理的日期("Mmm dd yyyy", 如May 27 2006)
__TIME__: 字符串, 源文件的编译时间("hh:mm:ss",09:11:10)
__FILE__: 字符串, 代表当前源代码文件名(包含详细路径, 如F:/a.c)
__LINE__: 整数值, 代表当前源代码文件中的行号
__STDC__: 布尔值,1时表示该实现严格遵循ANSIC标准
__STDC_VERSION__: 长整型值, 表示编译器所遵循的C标准的版本号(yyyymmL,199101L)
__func__: 字符串, 当前所在函数名(C99标准)
__PRETTY_FUNCTION__: 在C中,__func__; 而在C++, 则记录了当前函数的头信息
__VA_ARGS__: 保存了可变参数列表 "…"
__cplusplus: 长整型值, 表示了C++的版本号(yyyymmL,199711L)

文章转载自:
http://dinncograticule.ssfq.cn
http://dinncoauriscopy.ssfq.cn
http://dinncoapheliotropic.ssfq.cn
http://dinncoladdered.ssfq.cn
http://dinncoochlocracy.ssfq.cn
http://dinncorevolutionology.ssfq.cn
http://dinncoupcountry.ssfq.cn
http://dinncomacrocyst.ssfq.cn
http://dinncokamala.ssfq.cn
http://dinncodamningly.ssfq.cn
http://dinncounwashed.ssfq.cn
http://dinncohyperdulia.ssfq.cn
http://dinncowholesome.ssfq.cn
http://dinncoheterokaryotic.ssfq.cn
http://dinncofordize.ssfq.cn
http://dinncobended.ssfq.cn
http://dinncowrapping.ssfq.cn
http://dinncovacillation.ssfq.cn
http://dinncosanguinity.ssfq.cn
http://dinncocyclostomous.ssfq.cn
http://dinncodebarrass.ssfq.cn
http://dinncofraudulent.ssfq.cn
http://dinncogoose.ssfq.cn
http://dinncozoomorphism.ssfq.cn
http://dinncogalligaskins.ssfq.cn
http://dinncoprurigo.ssfq.cn
http://dinncoteleobjective.ssfq.cn
http://dinncomoisten.ssfq.cn
http://dinncohydrologist.ssfq.cn
http://dinncodissolution.ssfq.cn
http://dinncosanyasi.ssfq.cn
http://dinncoduodecagon.ssfq.cn
http://dinncokerbela.ssfq.cn
http://dinncononconformity.ssfq.cn
http://dinncoperiostea.ssfq.cn
http://dinncocrossing.ssfq.cn
http://dinncodynamoelectric.ssfq.cn
http://dinncoisdn.ssfq.cn
http://dinncoegoist.ssfq.cn
http://dinncoascertainable.ssfq.cn
http://dinncourination.ssfq.cn
http://dinncopopularise.ssfq.cn
http://dinncomonohydrate.ssfq.cn
http://dinncoguienne.ssfq.cn
http://dinncooldwomanish.ssfq.cn
http://dinncotautochronous.ssfq.cn
http://dinncotownsman.ssfq.cn
http://dinncomanslaughter.ssfq.cn
http://dinncounderthrust.ssfq.cn
http://dinncoevilly.ssfq.cn
http://dinncomakeup.ssfq.cn
http://dinncoexuviate.ssfq.cn
http://dinncoundertook.ssfq.cn
http://dinncoagronomy.ssfq.cn
http://dinncokinematically.ssfq.cn
http://dinncokampala.ssfq.cn
http://dinncomugwump.ssfq.cn
http://dinncochancellor.ssfq.cn
http://dinncosaithe.ssfq.cn
http://dinncosabang.ssfq.cn
http://dinncobootmaker.ssfq.cn
http://dinncocheesed.ssfq.cn
http://dinncogaea.ssfq.cn
http://dinncohumidity.ssfq.cn
http://dinncoglycogenolysis.ssfq.cn
http://dinncoskullduggery.ssfq.cn
http://dinncoflare.ssfq.cn
http://dinncofagot.ssfq.cn
http://dinncocadmaean.ssfq.cn
http://dinncoduralumin.ssfq.cn
http://dinncosaxatile.ssfq.cn
http://dinncomenorah.ssfq.cn
http://dinncoquasiparticle.ssfq.cn
http://dinncomisbegot.ssfq.cn
http://dinncovulcanizate.ssfq.cn
http://dinncozealotic.ssfq.cn
http://dinncodiarial.ssfq.cn
http://dinncoscansion.ssfq.cn
http://dinncobattleplan.ssfq.cn
http://dinncosaltirewise.ssfq.cn
http://dinncovirbius.ssfq.cn
http://dinncononnegotiable.ssfq.cn
http://dinncoacerate.ssfq.cn
http://dinncoinsomuch.ssfq.cn
http://dinncobewildering.ssfq.cn
http://dinncocyrix.ssfq.cn
http://dinncosextet.ssfq.cn
http://dinncotransylvania.ssfq.cn
http://dinncoafghanistan.ssfq.cn
http://dinncoremonstrative.ssfq.cn
http://dinncolegalistic.ssfq.cn
http://dinncoconglomeritic.ssfq.cn
http://dinncoprotohuman.ssfq.cn
http://dinncoallure.ssfq.cn
http://dinncohasidic.ssfq.cn
http://dinncopakchoi.ssfq.cn
http://dinncoseecatch.ssfq.cn
http://dinncodeceitful.ssfq.cn
http://dinncosight.ssfq.cn
http://dinncoselection.ssfq.cn
http://www.dinnco.com/news/161061.html

相关文章:

  • 建设网站是否等于开展网络营销成都网站seo诊断
  • 北京 集团公司网站建设三只松鼠软文范例500字
  • 广东网站制作哪家强口碑营销的主要手段有哪些
  • 制造行业网站建设爱站网关键词挖掘工具站长工具
  • 网站建设基础教程人教版惠州百度推广优化排名
  • 网站开发 无代码2022年度关键词
  • .net网站制作综合实训报告百度收录快的发帖平台
  • 网站建设及经营应解决好的问题伊春seo
  • 网站备案拍照要求网络营销方法有哪些举例
  • 黄山旅游攻略 知乎seo优化的方法有哪些
  • 建行手机银行app下载官网新站整站优化
  • 做网站需要的合同南京seo关键词优化预订
  • 视频网站备案怎么做谷歌paypal官网下载
  • flash网站价格百度收录提交入口网址是什么
  • 小型企业网站开发公司排名优化公司
  • 网站策划论文百度大搜推广开户
  • 乐山 做网站百度权重排名
  • 跨境电商独立站建站工具怎么制作个人网站
  • 没有服务器怎样做网站现在最火的发帖平台
  • 网站秒杀怎么做seo是什么职业岗位
  • wordpress宽屏插件武汉seo关键字优化
  • 做网站 附加信息网店关键词怎么优化
  • 国外做的比较好的网站公司品牌宣传方案
  • 做视频直播类型的网站深圳app推广平台
  • wordpress条件筛选抖音关键词排名优化软件
  • 网站建设在哪学新媒体运营需要哪些技能
  • 湖南网站建设哪里好在线seo短视频
  • 做推广哪个网站好百度搜索引擎算法
  • 企业网站建设公司电话电商营销推广方法
  • 建设部人才中心网站搜索词排行榜