English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
Avant de compiler un module Erlang, le préprocesseur Erlang traite automatiquement ce module. Le préprocesseur étend toute macro existante dans le fichier source et insère tous les fichiers inclus nécessaires.
通常,您不需要查看预处理器的输出,但在特殊情况下(例如,调试一个错误的宏时),您可能希望保存预处理器的输出。查看对模块some_module进行预处理的结果。erl给出操作系统的shell命令。
erlc -P some_module.erl
例如,假设我们有以下代码文件-
-module(helloworld). -export([start/0]). -include("user.hrl"). start() -> io:fwrite("~w",[?macro1(1,2)]).
如果我们从命令行执行以下命令-
erlc –P helloworld.erl
将生成一个名为 helloworld.P 的文件。如果您打开这个文件,您会发现以下内容,这是预处理程序将要编译的内容。
-file("helloworld.erl", 1). -module(helloworld). -export([start/0]). -file("user.hrl", 1). -file("helloworld.erl", 3). start() -> io:fwrite("~w", [{1 + 2}]).