Create a gist now

Instantly share code, notes, and snippets.

@roowe /a.hrl
Created Jan 8, 2017

What would you like to do?
头文件循环include
-ifndef(DEFINE_a_HRL).
-define(DEFINE_a_HRL, true).
-include("b.hrl").
-define(a, a).
-endif.
-ifndef(DEFINE_b_HRL).
-define(DEFINE_b_HRL, true).
-include("a.hrl").
-define(b, b).
-endif.
-module(main).
-export([start/0]).
start() ->
main1:start(),
main2:start(),
main3:start(),
ok.
-module(main1).
-include("a.hrl").
-export([start/0]).
start() ->
io:format("~p ~p~n", [?a, ?b]).
-module(main2).
-include("a.hrl").
-include("b.hrl").
-export([start/0]).
start() ->
io:format("~p ~p~n", [?a, ?b]).
-module(main3).
-include("b.hrl").
-export([start/0]).
start() ->
io:format("~p ~p~n", [?a, ?b]).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment