摘要
预处理在C/C++中发挥着重要作用,然而这些预处理功能存在着一些缺陷,例如在头文件包含进来时,无法改变头文件中的内容;代码的重用性不高;大量重复代码等等。本文提出用一种高级配置语言XVCL(XML-basedVariantConfigura-tionLanguage)代替原来的预处理机制,来克服以上提出的问题。文件被组织为树形结构,并定义了利于提高重用性的变量作用域机制。文章通过一个实例来验证本文提出的方法的有效性。
C and C++ are very popular languages. Macro preprocessing (C preprocessing, CPP in short) mechanism plays an important role in C and C++. However, there are some shortcomings in CPP. For example, the frigid inclusion mechanism makes it harder to change the contents before the header is included; code reuse is not efficient, there tends to be lots of replicated code both in the implementation files and header files. Other problems include cross including effects problem, macro scoping problem, etc. In this paper, a method is presented with XVCL to alleviate these problems. Files are organized with tree structure to improve code reuse and provide a better variable functioning scope. With this approach, you can manipulate the importing file flexibly by inserting/deleting. And most important, you can reuse code more efficiently which makes maintenance much easier. At the end of this paper, the impact of our solutions is discussed.
出处
《微计算机信息》
北大核心
2006年第03X期281-284,154,共5页
Control & Automation
关键词
预处理
重用
XVCL
作用域
Preprocessing, Reuse, XVCL, Functioning Scope