# Is it possible to get the fieldnames of a struct inside a macro?

**URL:** <https://discourse.julialang.org/t/is-it-possible-to-get-the-fieldnames-of-a-struct-inside-a-macro/33314>\
**Category:** General Usage\
**Created:** [January 13, 2020, 8:44pm UTC](https://discourse.julialang.org/t/is-it-possible-to-get-the-fieldnames-of-a-struct-inside-a-macro/33314 "2020-01-13T20:44:53Z")\
**Posts on this page:** 1\
**Showing post:** 12

<div class="post-metadata">

**Author:** ![rdeits](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rdeits/32/286_2.png) [@rdeits](https://discourse.julialang.org/u/rdeits)\
**Post date:** [January 13, 2020, 10:38pm UTC](https://discourse.julialang.org/t/is-it-possible-to-get-the-fieldnames-of-a-struct-inside-a-macro/33314/12 "2020-01-13T22:38:20Z")

</div>

> [@rvignolo](#):
>
> I was wondering if it is possible to expand or get fieldnames of a DataType inside a macro

No, for exactly the same reasons as in [Unpack named tuples (does anyone know how to do it?) - #9 by rdeits](https://discourse.julialang.org/t/unpack-named-tuples-does-anyone-know-how-to-do-it/32456/9)

The macro is, in general, expanded before the struct exists and certainly before the symbol being passed into the macro has a value. This just isn’t something macros can do for you, at least not in a way you can rely on.

An `@generated` function is probably the solution here, although it’s hard to know without knowing what you’re actually trying to accomplish. Can you give any more context?

---

_[View the full topic](https://discourse.julialang.org/t/is-it-possible-to-get-the-fieldnames-of-a-struct-inside-a-macro/33314)._
