diff --git a/src/include/types.h b/src/include/types.h
index 148cf2e2640458f1cf388061f7bb50a6cbbe6ff6..0271769a73600adc8de3ff6dfe1cf4d9d0f8a49f 100644
--- a/src/include/types.h
+++ b/src/include/types.h
@@ -17,12 +17,12 @@ typedef __complex__ double dcomplex;
  * \param z: `complex double` The argument of the function.
  * \return rz: `double` The real part of the argument.
  */
-double real(dcomplex z) { return __real__ z; }
+double real(dcomplex z);
 
 /*! \brief Get the imaginary part of a complex number.
  *
  * \param z: `complex double` The argument of the function.
  * \return iz: `double` The imaginary part of the argument.
  */
-double imag(dcomplex z) { return __imag__ z; }
+double imag(dcomplex z);
 #endif
diff --git a/src/libnptm/types.cpp b/src/libnptm/types.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..a9fd71be5682403b831ca13926fb6eff88ebac69
--- /dev/null
+++ b/src/libnptm/types.cpp
@@ -0,0 +1,13 @@
+/* Distributed under the terms of GPLv3 or later. See COPYING for details. */
+
+/*! \file types.cpp
+ *
+ * \brief Implementation of the functions connected with types.
+ */
+#ifndef INCLUDE_TYPES_H_
+#include "../include/types.h"
+#endif
+
+double real(dcomplex z) { return __real__ z; }
+
+double imag(dcomplex z) { return __imag__ z; }