How to use Erlang Macros in Elixir code

I have one application which is written in erlang. Now I wrote another application in Elixir which will use marcos of erlang application.
How can I use the erlang macros in elixir code?

You cannot, as Erlang macros and Elixir macros are in completely different worlds. You need to rewrite them into Elixir macros.

1 Like

You can also write erlang modules in your application.


I am using third party erlang application so I know only the macro names but not its value, so how can i rewrite them in Elixir?

Eventhough if i rewrite the macros in elixir, Same macro names will be present in erlang and elixir. Will it give any conflict on macro names?

Yes, we can use erlang modules in my application. but issue is how can I use macros defined in erlang module to elixir application

Erlang defines are not bound to modules, they are just compile time stuff. There will be no clash.

Erlang macros are just preprocessor macros, like #define in C preprocessor, so there is absolutely no “run-time” name that could clash.

Thanks for the reply guys. I will try to rewrite the macros in elixir.