我读到Objective-C是通过使用预处理器指令将Smalltalk的功能添加到C,这让我有点好奇,因此我开始修改C++中的预处理器,仅仅因为我是无聊与此想出了:使用预处理器来更改语言语法
#include <iostream>
#include <string>
#define Constant const
#define Integer int
#define Real double
#define Boolean bool
#define Character char
#define String string;
#define System system
#define StandardLibrary std
#define OutputStream cout
int main()
{
Integer i = 1;
Integer ii = 2;
Integer iii = ii + i;
StandardLibrary::OutputStream<<iii;
System("pause");
return 0;
}
所以,是的,这是很明显,你可以更改使用预处理器的名称,但它是如何可以实现一种语言的功能集成到使用预处理器的另一种语言?
我不打算通过这个使我自己的语言。我只是好奇,看看它是如何工作的。
有什么问题吗? –
你做了什么改进,甚至有帮助?顺便说一句,你可以使用'typedef'或'using'来完成你所做的大部分事情。 –
不是!我只想知道如何使用预处理器将一种语言的特性实现到另一种语言中。 –