# macros vs functions (One breaks my map, the other doesnt)

**URL:** <https://forums.unrealengine.com/t/macros-vs-functions-one-breaks-my-map-the-other-doesnt/2331736>\
**Category:** Programming & Scripting\
**Tags:** UE-5, unreal-engine, UE5, Blueprint, question, UE503\
**Created:** [February 13, 2025, 10:56pm UTC](https://forums.unrealengine.com/t/macros-vs-functions-one-breaks-my-map-the-other-doesnt/2331736 "2025-02-13T22:56:44Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![nande](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/nande/32/1057698_2.png) [@nande](https://forums.unrealengine.com/u/nande)\
**Post date:** [February 14, 2025, 5:12am UTC](https://forums.unrealengine.com/t/macros-vs-functions-one-breaks-my-map-the-other-doesnt/2331736/5 "2025-02-14T05:12:14Z")

</div>

> [@Skyboy](#):
>
> Is there a metaphor to describe them and when I might use them?

rarely i’ve found a situation where i actually need a macro. when my teammates used them, they always ran into issues time later.  
is not because macros are bad, but because sometimes one might confuse their use.

i don’t think i’ll manage to succinctly explain what _i_ know about them but:  
in cpp macros are usually used to _generate_ code in a generic way. just snippets. on a higher level than the actual language. and so they are not constrained by things like “type”.

in bp they work a bit similar in that you can “reuse” chunks of code. it’s more like a copy/paste than a function. the code is executed locally. if you can use a function instead, i’d rather do that.  
if it has to be a “static global function” you can use a bp function library.

irrelevant thought:  
i think the for loop uses it because it is type agnostic, and have multiple execution pins. but i don’t understand why epic decided to implement it in than fashion instead of a k2node, specially since a for loop is such a basic part of a language and it’s super related to performance. 🤷  
a caveat is that a for loop will evaluate the input on every loop, so if you use a pure function (which is very likely) that function gets evaluated on each loop, so you might want to cache the value first (afaik).

as for a metaphor?  
macros (at least in cpp) behave like a Find/Replace.  
it will find all the occurences of the macro, and then paste the code in between, before the compiler compiles it (afaik).

unfortunately ue’s docs is lacking on explaining how they work and why.

> **[Macros in Unreal Engine | Unreal Engine 5.5 Documentation | Epic Developer...](https://dev.epicgames.com/documentation/en-us/unreal-engine/macros-in-unreal-engine)**
>
> Collapsed networks of nodes that can be executed, or called, from another graph.

luckly there are nice ppl on the forums [What's the difference between Blueprint Macros and Blueprint Functions? - #10 by MulleDK19](https://forums.unrealengine.com/t/whats-the-difference-between-blueprint-macros-and-blueprint-functions/280809/10)

> **[Macros In C++ - GeeksforGeeks](https://www.geeksforgeeks.org/cpp-macros/)**
>
> A Computer Science portal for geeks. It contains well written, well thought and well explained computer science and programming articles, quizzes and practice/competitive programming/company interview Questions.

---

_[View the full topic](https://forums.unrealengine.com/t/macros-vs-functions-one-breaks-my-map-the-other-doesnt/2331736)._
