# Macro contexts defines

**URL:** <https://community.haxe.org/t/macro-contexts-defines/3443>\
**Category:** Haxe\
**Created:** [February 1, 2022, 5:38pm UTC](https://community.haxe.org/t/macro-contexts-defines/3443 "2022-02-01T17:38:47Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![filt3rek](https://community.haxe.org/user_avatar/community.haxe.org/filt3rek/32/2613_2.png) [@filt3rek](https://community.haxe.org/u/filt3rek)\
**Post date:** [February 1, 2022, 5:38pm UTC](https://community.haxe.org/t/macro-contexts-defines/3443/1 "2022-02-01T17:38:47Z")

</div>

Hej !

I want to call a function in macro initialization context (called from the .hxml file).  
This function is in a file that has some macro function and some not, separated by `#if macro` directives.

```haxe
public static function addDirectives(){
	if( haxe.macro.Compiler.getDefine( "a_define" ) != null ){
		haxe.macro.Compiler.define( "my_define" );
	}
}

```

If I put this function in `macro` section, compiler throws me `macro-in-macro` but if I put it in `!macro` compilers can’t find this function…

I think I could work if it was in another file but I don’t want to add a file just for one little macro initialization function.

is there any compiler directives that maybe kind of “separate” the macro contexts ?  
Something like `#if macro_init` ?

What are my possibilities please ?

Thanks for your answers !

---

<div class="post-metadata">

**Author:** ![filt3rek](https://community.haxe.org/user_avatar/community.haxe.org/filt3rek/32/2613_2.png) [@filt3rek](https://community.haxe.org/u/filt3rek)\
**Post date:** [February 1, 2022, 11:26pm UTC](https://community.haxe.org/t/macro-contexts-defines/3443/2 "2022-02-01T23:26:17Z")

</div>

If I define something using `haxe.macro.Compiler.define( "my_define" )` , it won’t be useable with `#my_define` right ?  
It will only be available by `haxe.macro.Context.defined()` or `haxe.macro.Compiler.getDefine()` right ?
