Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3404298
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T05:21:57+00:00 2026-05-18T05:21:57+00:00

In the recent Erlang R14, inets’ file httpd.hrl has been moved from: src/httpd.hrl to:

  • 0

In the recent Erlang R14, inets’ file httpd.hrl has been moved from:

src/httpd.hrl

to:

src/http_server/httpd.hrl

The Erlang Web framework includes the file in several places using the following directive:

-include_lib("inets/src/httpd.hrl").

Since I’d love the Erlang Web to compile with both versions of Erlang (R13 and R14), what I’d need ideally is:

-ifdef(OLD_ERTS_VERSION).
-include_lib("inets/src/httpd.hrl").
-else.
-include_lib("inets/src/http_server/httpd.hrl").
-endif.

Even if it possible to retrieve the ERTS version via:

erlang:system_info(version).

That’s indeed not possible at pre-processing time.

How to deal with these situations? Is the parse transform the only way to go? Are there better alternatives?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T05:21:58+00:00Added an answer on May 18, 2026 at 5:21 am

    Not sure if you’ll like this hackish trick, but you could use a parse transform.

    Let’s first define a basic parse transform module:

    -module(erts_v).
    -export([parse_transform/2]).
    
    parse_transform(AST, _Opts) ->
        io:format("~p~n", [AST]).
    

    Compile it, then you can include both headers in the module you want this to work for. This should give the following:

    -module(test).
    -compile({parse_transform, erts_v}).
    -include_lib("inets/src/httpd.hrl").
    -include_lib("inets/src/http_server/httpd.hrl").
    -export([fake_fun/1]).
    
    fake_fun(A) -> A.
    

    If you’re on R14B and compile it, you should have the abstract format of the module looking like this:

    [{attribute,1,file,{"./test.erl",1}},
     {attribute,1,module,test},
     {error,{3,epp,{include,lib,"inets/src/httpd.hrl"}}},
     {attribute,1,file,
         {"/usr/local/lib/erlang/lib/inets-5.5/src/http_server/httpd.hrl",1}},
     {attribute,1,file,
         {"/usr/local/lib/erlang/lib/kernel-2.14.1/include/file.hrl",1}},
     {attribute,24,record,
         {file_info,
             [{record_field,25,{atom,25,size}},
              {record_field,26,{atom,26,type}},
     ...
    

    What this tells us is that we can use both headers, and the valid one will automatically be included while the other will error out. All we need to do is remove the {error,...} tuple and get a working compilation. To do this, fix the parse_transform module so it looks like this:

    -module(erts_v).
    -export([parse_transform/2]).
    
    parse_transform(AST, _Opts) ->
        walk_ast(AST).
    
    walk_ast([{error,{_,epp,{include,lib,"inets/src/httpd.hrl"}}}|AST]) ->
        AST;
    walk_ast([{error,{_,epp,{include,lib,"inets/src/http_server/httpd.hrl"}}}|AST]) ->
        AST;
    walk_ast([H|T]) ->
        [H|walk_ast(T)].
    

    This will then remove the error include, only if it’s on the precise module you wanted. Other messy includes should fail as usual.

    I haven’t tested this on all versions, so if the behaviour changed between them, this won’t work. On the other hand, if it stayed the same, this parse_transform will be version independent, at the cost of needing to order the compiling order of your modules, which is simple enough with Emakefiles and rebar.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The recent documents feature in Office is really useful, but I moved a file
The recent update (V 20.x) of Chrome has broken one of my forms with
One of my recent works has some pretty strange bugs on the ipad. I
In my most recent attempt to access the XML database from my nightmares, I've
The recent MacBook Pro keyboard and the bluetooth keyboard layout has only one Control
A recent introduction to Smalltalk has enlightened me on the application and benefits of
A recent Delphi project i've inherited has a procedure in ASM. I'm a complete
Recent events are moving away developers from MySQL to alternatives such as MariaDB. (It
A recent project has called for the use of two Hiragino fonts on iOS
A recent blunder was made where the Bug Tracker .NET software was removed from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.