# Conditional use of modules and macros

**URL:** <https://discourse.julialang.org/t/conditional-use-of-modules-and-macros/51118>\
**Category:** New to Julia\
**Created:** [December 2, 2020, 2:33pm UTC](https://discourse.julialang.org/t/conditional-use-of-modules-and-macros/51118 "2020-12-02T14:33:03Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![FPGro](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fpgro/32/20822_2.png) [@FPGro](https://discourse.julialang.org/u/FPGro)\
**Post date:** [December 20, 2020, 10:04am UTC](https://discourse.julialang.org/t/conditional-use-of-modules-and-macros/51118/5 "2020-12-20T10:04:47Z")

</div>

> [@Is importing module is allowed inside @static?](https://discourse.julialang.org/t/is-importing-module-is-allowed-inside-static/28975/2):
>
> Yes it is. What you see errors for the same reason it errors without the @static, the macro needs to be evaluated BEFORE the toplevel expression (i.e. if ... or @static if ...) can run so the macro is evaluated BEFORE you imported the module. Repeat if twice, first with import and second time with the macro should work. Note that for the import/using you don’t need @static. You only need it for the @sk\_import since it’s a macro.

This fails for the same reason stated here, you need to split this into 2 “@static if…” clauses so the import is resolved before the macro is expanded

---

_[View the full topic](https://discourse.julialang.org/t/conditional-use-of-modules-and-macros/51118)._
