# Use of itkEventMacroDeclaration and itkEventMacroDefinition

**URL:** <https://discourse.itk.org/t/use-of-itkeventmacrodeclaration-and-itkeventmacrodefinition/1204>\
**Category:** Engineering\
**Tags:** macro, event\
**Created:** [August 16, 2018, 7:14am UTC](https://discourse.itk.org/t/use-of-itkeventmacrodeclaration-and-itkeventmacrodefinition/1204 "2018-08-16T07:14:14Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gordian](https://discourse.itk.org/user_avatar/discourse.itk.org/gordian/32/335_2.png) [@Gordian](https://discourse.itk.org/u/Gordian)\
**Post date:** [August 16, 2018, 7:14am UTC](https://discourse.itk.org/t/use-of-itkeventmacrodeclaration-and-itkeventmacrodefinition/1204/1 "2018-08-16T07:14:14Z")

</div>

Hi,

I am a little bit confused about the description of the use of itkEventMacroDeclaration and itkEventMacroDefinition:

```
// This macro duplicates some of the declaration and definition
// macro code. The purpose is to provide a backward compatibility API
// for ITK applications.
// NOTE: New applications should use itkEventMacroDeclaration (in a
// .h file) and itkEventMacroDefinition (in a compiled .cxx
// file). This new approach guarantees that only one copy of the
// implementation will be present.

```

from [itk::EventObject.h](https://github.com/InsightSoftwareConsortium/ITK/blob/master/Modules/Core/Common/include/itkEventObject.h), line 140-147.

in the past the usual way seemed to be just to put `itkEventMacro` in the header file where you want to use the event.  
The way I interpret the new approach is that all itkEventMacroDeclaration are put in an separate header file and the itkEventMacroDefinition are placed in a separate .cxx file. All classes that make use of an event are including the event header file.

What I tried so far:  
itkRegistrationEvents.h

```
#ifndef itkRegistrationEvents_h
#define itkRegistrationEvents_h

#include "itkEventObject.h"

namespace itk
{
	itkEventMacroDeclaration(BeforeEvaluationEvent, AnyEvent);
	itkEventMacroDeclaration(AfterEvaluationEvent, AnyEvent);
}

#endif itkRegistrationEvents_h

```

itkRegistrationEvents.cxx

```
#include "itkRegistrationEvents.h";

namespace itk
{
	itkEventMacroDefinition(BeforeEvaluationEvent, AnyEvent);
	itkEventMacroDefinition(AfterEvaluationEvent, AnyEvent);
}

```

The itkRegistrationEvents are included in the file where I want to invoke the event.  
**Is this the intended use?**

Thanks in advance,  
Gordian
