Skip to content

Instantly share code, notes, and snippets.

@roowe
Created January 8, 2017 08:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save roowe/6ce6968448b8f3bcacc7aae8c76719b2 to your computer and use it in GitHub Desktop.
Save roowe/6ce6968448b8f3bcacc7aae8c76719b2 to your computer and use it in GitHub Desktop.
头文件循环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