--- a/include/libcgroup/config.h
+++ b/include/libcgroup/config.h
@@ -5,12 +5,10 @@
 #error "Only <libcgroup.h> should be included directly."
 #endif
 
-#ifndef SWIG
-#include <features.h>
+#ifdef __cplusplus
+extern "C" {
 #endif
 
-__BEGIN_DECLS
-
 /**
  * @defgroup group_config 5. Configuration
  * @{
@@ -107,6 +105,8 @@ int cgroup_config_create_template_group(
  * @}
  * @}
  */
-__END_DECLS
+#ifdef __cplusplus
+}
+#endif
 
 #endif /*_LIBCGROUP_CONFIG_H*/
--- a/include/libcgroup/error.h
+++ b/include/libcgroup/error.h
@@ -5,12 +5,10 @@
 #error "Only <libcgroup.h> should be included directly."
 #endif
 
-#ifndef SWIG
-#include <features.h>
+#ifdef __cplusplus
+extern "C" {
 #endif
 
-__BEGIN_DECLS
-
 /**
  * @defgroup group_errors 6. Error handling
  * @{
@@ -99,6 +97,8 @@ int cgroup_get_last_errno(void);
  * @}
  * @}
  */
-__END_DECLS
+#ifdef __cplusplus
+}
+#endif
 
 #endif /* _LIBCGROUP_INIT_H */
--- a/include/libcgroup/groups.h
+++ b/include/libcgroup/groups.h
@@ -6,12 +6,13 @@
 #endif
 
 #ifndef SWIG
-#include <features.h>
 #include <sys/types.h>
 #include <stdbool.h>
 #endif
 
-__BEGIN_DECLS
+#ifdef __cplusplus
+extern "C" {
+#endif
 
 /**
  * Flags for cgroup_delete_cgroup_ext().
@@ -577,6 +578,8 @@ char *cgroup_get_cgroup_name(struct cgroup *cgroup);
  */
 
 
-__END_DECLS
+#ifdef __cplusplus
+}
+#endif
 
 #endif /* _LIBCGROUP_GROUPS_H */
--- a/include/libcgroup/init.h
+++ b/include/libcgroup/init.h
@@ -5,12 +5,10 @@
 #error "Only <libcgroup.h> should be included directly."
 #endif
 
-#ifndef SWIG
-#include <features.h>
+#ifdef __cplusplus
+extern "C" {
 #endif
 
-__BEGIN_DECLS
-
 /**
  * @defgroup group_init 1. Initialization
  * @{
@@ -58,6 +56,8 @@ int cgroup_get_subsys_mount_point(const char *controller, char **mount_point);
  * @}
  * @}
  */
-__END_DECLS
+#ifdef __cplusplus
+}
+#endif
 
 #endif /* _LIBCGROUP_INIT_H */
--- a/include/libcgroup/iterators.h
+++ b/include/libcgroup/iterators.h
@@ -8,10 +8,11 @@
 #ifndef SWIG
 #include <sys/types.h>
 #include <stdio.h>
-#include <features.h>
 #endif
 
-__BEGIN_DECLS
+#ifdef __cplusplus
+extern "C" {
+#endif
 
 /**
  * @defgroup group_iterators 3. Iterators
@@ -423,6 +424,8 @@ int cgroup_get_subsys_mount_point_end(void **handle);
  * @}
  */
 
-__END_DECLS
+#ifdef __cplusplus
+}
+#endif
 
 #endif /* _LIBCGROUP_ITERATORS_H */
--- a/include/libcgroup/log.h
+++ b/include/libcgroup/log.h
@@ -5,13 +5,11 @@
 #error "Only <libcgroup.h> should be included directly."
 #endif
 
-#ifndef SWIG
-#include <features.h>
-#endif
-
 #include <stdarg.h>
 
-__BEGIN_DECLS
+#ifdef __cplusplus
+extern "C" {
+#endif
 
 /**
  * @defgroup group_log 7. Logging
@@ -142,6 +140,8 @@ extern int cgroup_parse_log_level_str(const char *levelstr);
  * @}
  * @}
  */
-__END_DECLS
+#ifdef __cplusplus
+}
+#endif
 
 #endif /* _LIBCGROUP_LOG_H */
--- a/include/libcgroup/tasks.h
+++ b/include/libcgroup/tasks.h
@@ -8,11 +8,12 @@
 #include <libcgroup/groups.h>
 
 #ifndef SWIG
-#include <features.h>
 #include <stdbool.h>
 #endif
 
-__BEGIN_DECLS
+#ifdef __cplusplus
+extern "C" {
+#endif
 
 /** Flags for cgroup_change_cgroup_uid_gid(). */
 enum cgflags {
@@ -204,6 +205,8 @@ int cgroup_register_unchanged_process(pid_t pid, int flags);
  * @}
  * @}
  */
-__END_DECLS
+#ifdef __cplusplus
+}
+#endif
 
 #endif /* _LIBCGROUP_TASKS_H */
--- a/src/daemon/cgrulesengd.h
+++ b/src/daemon/cgrulesengd.h
@@ -15,9 +15,9 @@
 #ifndef _CGRULESENGD_H
 #define _CGRULESENGD_H
 
-#include <features.h>
-
-__BEGIN_DECLS
+#ifdef __cplusplus
+extern "C" {
+#endif
 
 #include "config.h"
 #include "libcgroup.h"
@@ -119,7 +119,9 @@ void cgre_flash_templates(int signum);
  */
 void cgre_catch_term(int signum);
 
-__END_DECLS
+#ifdef __cplusplus
+}
+#endif
 
 #endif /* _CGRULESENGD_H */
 
--- a/src/libcgroup-internal.h
+++ b/src/libcgroup-internal.h
@@ -16,7 +16,9 @@
 
 #define __LIBCG_INTERNAL
 
-__BEGIN_DECLS
+#ifdef __cplusplus
+extern "C" {
+#endif
 
 #include "config.h"
 #include <fts.h>
@@ -279,6 +281,8 @@ extern void cgroup_dictionary_iterator_end(void **handle);
  */
 int cg_chmod_path(const char *path, mode_t mode, int owner_is_umask);
 
-__END_DECLS
+#ifdef __cplusplus
+}
+#endif
 
 #endif