# UCLASS, UFUNCTION support inside macros request

**URL:** <https://forums.unrealengine.com/t/uclass-ufunction-support-inside-macros-request/397362>\
**Category:** Platform & Builds\
**Tags:** uht, macros, unreal-engine, ubt, question\
**Created:** [July 13, 2017, 9:39am UTC](https://forums.unrealengine.com/t/uclass-ufunction-support-inside-macros-request/397362 "2017-07-13T09:39:56Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![broly](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@broly](https://forums.unrealengine.com/u/broly)\
**Post date:** [July 13, 2017, 9:39am UTC](https://forums.unrealengine.com/t/uclass-ufunction-support-inside-macros-request/397362/1 "2017-07-13T09:39:56Z")

</div>

It’s will be great if we will able to place `UCLASS`, `UFUNCTION`, etc inside macros and it will be work after substitution.

For example, higher level code generation.

```
#define DECLARE_SUPERCLASS(cls_name) \
   UCLASS()
   class MY_API U##cls_name : public UObject\
   {\
         ...\
   }

```

Thanks 🙂

---

<div class="post-metadata">

**Author:** ![Vawx](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Vawx](https://forums.unrealengine.com/u/Vawx)\
**Post date:** [July 14, 2017, 2:38am UTC](https://forums.unrealengine.com/t/uclass-ufunction-support-inside-macros-request/397362/2 "2017-07-14T02:38:34Z")

</div>

This works for me:

```
#define DECLARE_SUPERCLASS(api_name, cls_name) \
UCLASS()\
class api_name U##cls_name : public UObject\
{\
\
};\

```

I tested in a engine plugin, which is why I substituted the MY\_API with the argument.

---

<div class="post-metadata">

**Author:** ![broly](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@broly](https://forums.unrealengine.com/u/broly)\
**Post date:** [July 14, 2017, 9:33am UTC](https://forums.unrealengine.com/t/uclass-ufunction-support-inside-macros-request/397362/3 "2017-07-14T09:33:08Z")

</div>

I’ve tested this and got error `../Classes/Utils.h(1): error : Missing 'class' in Class declaration Missing 'class' in Class declaration`.

![202338-customclass.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/8/3/4/834c2b918866e9aabe3ca28828fe3633eb75cd14.png)

---

<div class="post-metadata">

**Author:** ![Vawx](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Vawx](https://forums.unrealengine.com/u/Vawx)\
**Post date:** [July 15, 2017, 3:50am UTC](https://forums.unrealengine.com/t/uclass-ufunction-support-inside-macros-request/397362/4 "2017-07-15T03:50:47Z")

</div>

Yeah it doesn’t like the GENERATED\_BODY() or UPROPERTY( )

You’ll probably need another way to generate this code.

---

<div class="post-metadata">

**Author:** ![Jackblue](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/jackblue/32/88706_2.png) [@Jackblue](https://forums.unrealengine.com/u/Jackblue)\
**Post date:** [July 16, 2017, 9:12pm UTC](https://forums.unrealengine.com/t/uclass-ufunction-support-inside-macros-request/397362/5 "2017-07-16T21:12:02Z")

</div>

This is a normal behavior because UHT parse header before compiler replace macro.

The solution will be to replace some kind of macro with UHT, parse to scan UCLASS and UFUNCTION properties, and finally compiler replace last macros. Hope one day Epic improve this tool 🙂
