本文介绍了备用功能名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 这个问题是语言和编程之间的界限,但我想 更多地关注语言标准问题,而不是编程问题, 所以我发帖这里。 我有许多函数,这些函数由宏前端结束,这些函数在函数调用方式上发生了一些变化。完成各种各样的事情,但是一个简单的例子是一个函数,它接受一个变量数字($ char $ *)的并将所有字符串连接成一个单个 字符串,其中NULL是参数末尾的标记。宏的 前端添加了NULL,因此调用程序的细节不那么杂乱。 我一直在做的是给宏接口名称和 命名功能略有不同。我一直在说_在前面 的函数名称,我想放弃它。所以我有一个宏 喜欢: #define strjoin(a ...)(_ strjoin(a,((const char *)(NULL)))) 和一个函数定义如: char * _strjoin(const char * s,...) 替代我'我正在看的是对于宏 和函数使用相同的名称,例如: #define strjoin(a ...)((strjoin)(a ,((const char *)(NULL)))) 和: char *(strjoin)(const char * s,...) 这种方法有效,但我担心它可能引起的混乱。所以我想在这里做的就是看看有没有比上面显示的更好的替代方法来使用不同的 函数名。会有很多_人物帮助 避免冲突?喜欢也许: #define strjoin(a ...)(_ _ strjoin __(a,((const char *)(NULL)))) 和: char * __ strjoin __(const char * s,...) - ---------- -------------------------------------------------- ----------------- | Phil Howard KA9WGN | http://linuxhomepage.com/ http://ham.org/ | | (名字)在ipal.net | http://phil.ipal.org/ http://ka9wgn.ham.org/ | --------- -------------------------------------------------- ------------------This question is borderline between language and programming, but I want tofocus more on the language standards issue, rather than the programming issue,so I am posting here.I have a number of functions which are front-ended by macros which make somechanges in the way the functions are called. There are various things beingdone, but one simple example would be a function that takes a variable numberof (const char *) arguments and joins all the strings together into a singlestring, where a NULL is the sentinel at the end of the arguments. The macrofront end adds that NULL so the calling program is less cluttered with detail.What I have been doing with this is giving the macro the interface name andnaming the function slightly different. I have been putting a "_" in frontof the function name, which I want to get away from doing. So I have a macrolike:#define strjoin(a...) (_strjoin(a,((const char*)(NULL))))and a function definition like:char *_strjoin(const char *s,...)The alternative I''m looking at is to just use the same name for both macroand function, like:#define strjoin(a...) ((strjoin)(a,((const char*)(NULL))))and:char *(strjoin)(const char *s,...)This approach works, but I''m worried about confusion it may cause. So what Iwant to do here is see if there is a better alternative to using a differentfunction name than the one shown above. Would lots of "_" characters helpavoid conflicts? Like maybe:#define strjoin(a...) (__strjoin__(a,((const char*)(NULL))))and:char *__strjoin__(const char *s,...)-------------------------------------------------------------------------------| Phil Howard KA9WGN | http://linuxhomepage.com/ http://ham.org/ || (first name) at ipal.net | http://phil.ipal.org/ http://ka9wgn.ham.org/ |-----------------------------------------------------------------------------推荐答案 实际上,str_没关系str前缀仅在以小写字母跟随 时保留。 保留标识符包括: 是[abcdefghijklmnopqrstuvwxyz] * 到[abcdefghijklmnopqrstuvwxyz] * cerf cerfc cexp2 cexpm1 clog10 clog1p clog2 clgamma ctgamma cerf [fl] cerfc [fl] cexp2 [fl] cexpm1 [fl] clog10 [fl] clog1p [fl] clog2 [fl] clgamma [fl] ctgamma [fl] E [0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ] * PRI [abcdefghijklmnopqrstuvwxyzX] * SCN [abcdefghijklmnopqrstuvwxyzX] * LC_ [ABCDEFGHIJKLMNOPQRSTUVWXYZ] * SIG [ABCDEFGHIJKLMNOPQRSTUVWXYZ] * SIG_ [ABCDEFGHIJKLMNOPQRSTUVWXYZ] * int * _t uint * _t INT * _MAX INT * _MIN INT * _C UINT * _MAX UINT * _MIN UI NT * _C str [abcdefghijklmnopqrstuvwxyz] * mem [abcdefghijklmnopqrstuvwxyz] * wcs [abcdefghijklmnopqrstuvwxyz] * - Simon。Actually, "str_" is OK. The str prefix is only reserved when followedby a lowercase letter.Reserved identifiers include:is[abcdefghijklmnopqrstuvwxyz]*to[abcdefghijklmnopqrstuvwxyz]*cerfcerfccexp2cexpm1clog10clog1pclog2clgammactgammacerf[fl]cerfc[fl]cexp2[fl]cexpm1[fl]clog10[fl]clog1p[fl]clog2[fl]clgamma[fl]ctgamma[fl]E[0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ]*PRI[abcdefghijklmnopqrstuvwxyzX]*SCN[abcdefghijklmnopqrstuvwxyzX]*LC_[ABCDEFGHIJKLMNOPQRSTUVWXYZ]*SIG[ABCDEFGHIJKLMNOPQRSTUVWXYZ]*SIG_[ABCDEFGHIJKLMNOPQRSTUVWXYZ]*int*_tuint*_tINT*_MAXINT*_MININT*_CUINT*_MAXUINT*_MINUINT*_Cstr[abcdefghijklmnopqrstuvwxyz]*mem[abcdefghijklmnopqrstuvwxyz]*wcs[abcdefghijklmnopqrstuvwxyz]*--Simon. 这篇关于备用功能名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-14 04:37