diff --git a/aes.h b/aes.h
index 97d8deefe599c4089b6294e08cd3b6560b32b431..10c567f3676552d19f07bff913f88e1bda978308 100644
--- a/aes.h
+++ b/aes.h
@@ -28,6 +28,10 @@
 
 #include "nettle-types.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /* Name mangling */
 #define aes_set_encrypt_key nettle_aes_set_encrypt_key
 #define aes_set_decrypt_key nettle_aes_set_decrypt_key
@@ -65,4 +69,8 @@ aes_decrypt(struct aes_ctx *ctx,
 	    unsigned length, uint8_t *dst,
 	    const uint8_t *src);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* NETTLE_AES_H_INCLUDED */
diff --git a/arcfour.h b/arcfour.h
index 66891f8a900c5196cf538de79549060d0b3d8a45..f8e668929893ee7a9c44188af0137bb53a5053df 100644
--- a/arcfour.h
+++ b/arcfour.h
@@ -28,6 +28,10 @@
 
 #include "nettle-types.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /* Name mangling */
 #define arcfour_set_key nettle_arcfour_set_key
 #define arcfour_crypt nettle_arcfour_crypt
@@ -59,5 +63,9 @@ void
 arcfour_stream(struct arcfour_ctx *ctx,
 	       unsigned length, uint8_t *dst);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* NETTLE_ARCFOUR_H_INCLUDED */
 
diff --git a/arctwo.h b/arctwo.h
index 852564ac906e1299ebed42f6867ef1ac5e9ce9e5..fa1360de52fdbe11b0f72ab63e5be46e289cdbbf 100644
--- a/arctwo.h
+++ b/arctwo.h
@@ -29,6 +29,10 @@
 
 #include "nettle-types.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /* Name mangling */
 #define arctwo_set_key nettle_arctwo_set_key
 #define arctwo_set_key_ekb nettle_arctwo_set_key_ekb
@@ -73,4 +77,8 @@ void
 arctwo_decrypt (struct arctwo_ctx *ctx,
 		unsigned length, uint8_t *dst, const uint8_t *src);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* NETTLE_ARCTWO_H_INCLUDED */
diff --git a/asn1.h b/asn1.h
index dde627dca34b2064a2a97797bf37814e82489c7c..a7bca6ec812ff6efc4c9d1c27a40d53ba5ec327d 100644
--- a/asn1.h
+++ b/asn1.h
@@ -28,6 +28,10 @@
 
 #include "nettle-types.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /* Name mangling */
 #define asn1_der_iterator_first nettle_asn1_der_iterator_first
 #define asn1_der_iterator_next nettle_asn1_der_iterator_next
@@ -133,4 +137,8 @@ int
 asn1_der_get_uint32(struct asn1_der_iterator *i,
 		    uint32_t *x);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* NETTLE_ASN1_H_INCLUDED */
diff --git a/base16.h b/base16.h
index 2631fae41451576052f1bf64a325692c6ed7b305..967da4d1ab38dd3aae8cef12c3ac41349e6d9297 100644
--- a/base16.h
+++ b/base16.h
@@ -29,6 +29,10 @@
 
 #include "nettle-types.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /* Name mangling */
 #define base16_encode_single nettle_base16_encode_single
 #define base16_encode_update nettle_base16_encode_update
@@ -95,4 +99,8 @@ base16_decode_update(struct base16_decode_ctx *ctx,
 int
 base16_decode_final(struct base16_decode_ctx *ctx);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* NETTLE_BASE16_H_INCLUDED */
diff --git a/base64.h b/base64.h
index 7da84c15b3afd0e030268c80c425fd5953b51e83..279dff992a0221571a1bbab6fae195473d3dadb7 100644
--- a/base64.h
+++ b/base64.h
@@ -28,6 +28,10 @@
 
 #include "nettle-types.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /* Name mangling */
 #define base64_encode_init nettle_base64_encode_init
 #define base64_encode_single nettle_base64_encode_single
@@ -142,4 +146,8 @@ base64_decode_update(struct base64_decode_ctx *ctx,
 int
 base64_decode_final(struct base64_decode_ctx *ctx);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* NETTLE_BASE64_H_INCLUDED */
diff --git a/bignum.h b/bignum.h
index a14f7d6732ecd896634fba26d3ae068cb0c8d0f9..38b30905f4eb8363598273a3f7a1b7872a35bdbd 100644
--- a/bignum.h
+++ b/bignum.h
@@ -31,6 +31,10 @@
 #include <gmp.h>
 #include "nettle-types.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /* Size needed for signed encoding, including extra sign byte if
  * necessary. */
 unsigned
@@ -94,4 +98,8 @@ int
 nettle_asn1_der_get_bignum(struct asn1_der_iterator *iterator,
 			   mpz_t x, unsigned limit);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* NETTLE_BIGNUM_H_INCLUDED */
diff --git a/blowfish.h b/blowfish.h
index 3d343c6d8ee2c4fe30041ec52c6ac5ecb7eb9bc4..9e6175d67d7e1ee3fb9036ae9564e954c78e864a 100644
--- a/blowfish.h
+++ b/blowfish.h
@@ -28,6 +28,10 @@
 
 #include "nettle-types.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /* Name mangling */
 #define blowfish_set_key nettle_blowfish_set_key
 #define blowfish_encrypt nettle_blowfish_encrypt
@@ -68,4 +72,8 @@ blowfish_decrypt(struct blowfish_ctx *ctx,
                  unsigned length, uint8_t *dst,
                  const uint8_t *src);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* NETTLE_BLOWFISH_H_INCLUDED */
diff --git a/buffer.h b/buffer.h
index 050b06ce3c797f8c1c6cabe1764212823aaefd49..466ad92a49e56cf426596a4b77fb947732b28f4f 100644
--- a/buffer.h
+++ b/buffer.h
@@ -28,6 +28,10 @@
 
 #include "realloc.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 struct nettle_buffer
 {
   uint8_t *contents;
@@ -87,4 +91,8 @@ int
 nettle_buffer_copy(struct nettle_buffer *dst,
 		   const struct nettle_buffer *src);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* NETTLE_BUFFER_H_INCLUDED */
diff --git a/cast128.h b/cast128.h
index b9437655e80b1ba2bf2a75c1eab2fd9da6f1dc9e..421a18e17c61aea9ba61e705a7873955a13c7ad9 100644
--- a/cast128.h
+++ b/cast128.h
@@ -34,6 +34,10 @@
 
 #include "nettle-types.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /* Name mangling */
 #define cast128_set_key nettle_cast128_set_key
 #define cast128_encrypt nettle_cast128_encrypt
@@ -66,4 +70,8 @@ cast128_decrypt(struct cast128_ctx *ctx,
 		unsigned length, uint8_t *dst,
 		const uint8_t *src);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* NETTLE_CAST128_H_INCLUDED */
diff --git a/cbc.h b/cbc.h
index 50335f84ed538fabf8b2f7309b6490a54833ef8c..13bf8dd8aef6a4e7843f2acd955ba43183ce2563 100644
--- a/cbc.h
+++ b/cbc.h
@@ -28,6 +28,10 @@
 
 #include "nettle-types.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /* Name mangling */
 #define cbc_encrypt nettle_cbc_encrypt
 #define cbc_decrypt nettle_cbc_decrypt
@@ -64,4 +68,8 @@ memcpy((ctx)->iv, (data), sizeof((ctx)->iv))
 		 sizeof((self)->iv), (self)->iv,	\
                  (length), (dst), (src)))
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* NETTLE_CBC_H_INCLUDED */
diff --git a/ctr.h b/ctr.h
index 95c16615ab6be450cd4077b1873a96d6396745f9..80abb6e8faa26011b984119f6faf8aeb7ed84fca 100644
--- a/ctr.h
+++ b/ctr.h
@@ -29,6 +29,10 @@
 
 #include "nettle-types.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /* Name mangling */
 #define ctr_crypt nettle_ctr_crypt
 
@@ -51,4 +55,8 @@ memcpy((ctx)->ctr, (data), sizeof((ctx)->ctr))
 	       sizeof((self)->ctr), (self)->ctr,	\
                (length), (dst), (src)))
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* NETTLE_CTR_H_INCLUDED */
diff --git a/des-compat.h b/des-compat.h
index 5545e548862a39156cfb54a0a37f5425ea663582..d005a7ed23fdd8829626ebe1296eb0c8c827406a 100644
--- a/des-compat.h
+++ b/des-compat.h
@@ -35,6 +35,10 @@
 
 #include "des.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /* We use some name mangling, to avoid collisions with either other
  * nettle functions or with libcrypto. */
 
@@ -143,4 +147,8 @@ des_key_sched(const_des_cblock *key, des_key_schedule ctx);
 int
 des_is_weak_key(const_des_cblock *key);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* NETTLE_DES_COMPAT_H_INCLUDED */
diff --git a/des.h b/des.h
index 57e20250138d69266a39a32cc1e962dd3db762f1..b9de4caa36eb4fc28b8bb3f2bc7c17cfcaa97973 100644
--- a/des.h
+++ b/des.h
@@ -37,6 +37,10 @@
 
 #include "nettle-types.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /* Namespace mangling */
 #define des_set_key nettle_des_set_key
 #define des_encrypt nettle_des_encrypt
@@ -102,4 +106,8 @@ des3_decrypt(const struct des3_ctx *ctx,
 	     unsigned length, uint8_t *dst,
 	     const uint8_t *src);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* NETTLE_DES_H_INCLUDED */
diff --git a/dsa.h b/dsa.h
index 1f06136f2f56a3cc381f324af7a72a6162832e13..6190c77f7638a7d4ade5bf0ec3e50bc9a6053f7c 100644
--- a/dsa.h
+++ b/dsa.h
@@ -35,6 +35,10 @@
 /* For nettle_random_func */
 #include "nettle-meta.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /* Name mangling */
 #define dsa_public_key_init nettle_dsa_public_key_init
 #define dsa_public_key_clear nettle_dsa_public_key_clear
@@ -191,4 +195,8 @@ dsa_keypair_from_sexp(struct dsa_public_key *pub,
 		      unsigned length, const uint8_t *expr);
 
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* NETTLE_DSA_H_INCLUDED */
diff --git a/hmac.h b/hmac.h
index a89fb2ee6f84355de789fb0d497fc5847574edc5..09b8ba9970c614cb0877dd726c3ed5624cf9f155 100644
--- a/hmac.h
+++ b/hmac.h
@@ -31,6 +31,10 @@
 #include "md5.h"
 #include "sha.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /* Namespace mangling */
 #define hmac_set_key nettle_hmac_set_key
 #define hmac_update nettle_hmac_update
@@ -122,4 +126,8 @@ void
 hmac_sha256_digest(struct hmac_sha256_ctx *ctx,
 		   unsigned length, uint8_t *digest);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* NETTLE_HMAC_H_INCLUDED */
diff --git a/knuth-lfib.h b/knuth-lfib.h
index 073c9df501a50dc6608175e41d3238ad9071dcb4..b52393e4a7c21504289615902926ece1766be53c 100644
--- a/knuth-lfib.h
+++ b/knuth-lfib.h
@@ -33,6 +33,10 @@
 
 #include "nettle-types.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /* Namespace mangling */
 #define knuth_lfib_init nettle_knuth_lfib_init
 #define knuth_lfib_get nettle_knuth_lfib_get
@@ -64,4 +68,8 @@ void
 knuth_lfib_random(struct knuth_lfib_ctx *ctx,
 		  unsigned n, uint8_t *dst);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* NETTLE_KNUTH_LFIB_H_INCLUDED */
diff --git a/md2.h b/md2.h
index 2fbfbbccd06f43cc03ff65782488c45cc624978f..ac1cf33b518ceecac3900a9794b1f9ea834031a3 100644
--- a/md2.h
+++ b/md2.h
@@ -28,6 +28,10 @@
 
 #include "nettle-types.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /* Name mangling */
 #define md2_init nettle_md2_init
 #define md2_update nettle_md2_update
@@ -58,4 +62,8 @@ md2_digest(struct md2_ctx *ctx,
 	   uint8_t *digest);
 
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* NETTLE_MD2_H_INCLUDED */
diff --git a/md4.h b/md4.h
index 7ccf8c33dea345e1c6a7b610c00c0d9a56909e83..e9a32b9e15a8ccf490605a063e0cd2166c6c27eb 100644
--- a/md4.h
+++ b/md4.h
@@ -28,6 +28,10 @@
 
 #include "nettle-types.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /* Name mangling */
 #define md4_init nettle_md4_init
 #define md4_update nettle_md4_update
@@ -61,4 +65,8 @@ md4_digest(struct md4_ctx *ctx,
 	   uint8_t *digest);
 
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* NETTLE_MD4_H_INCLUDED */
diff --git a/md5-compat.h b/md5-compat.h
index 32925d09be5ec971159fd7a442c8b7ee6a284556..8f5f3318fa8ca2de6024cfe1eb507a95c1ec157b 100644
--- a/md5-compat.h
+++ b/md5-compat.h
@@ -28,6 +28,10 @@
 
 #include "md5.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /* Name mangling */
 #define MD5Init nettle_MD5Init
 #define MD5Update nettle_MD5Update
@@ -39,4 +43,8 @@ void MD5Init(MD5_CTX *ctx);
 void MD5Update(MD5_CTX *ctx, const unsigned char *data, unsigned int length);
 void MD5Final(unsigned char *out, MD5_CTX *ctx);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* NETTLE_MD5_COMPAT_H_INCLUDED */
diff --git a/md5.h b/md5.h
index c06c2288813679d20f5ac013b24d2704924146e6..c936cb269fcb828588a5a53ad4847bf2706fd6bd 100644
--- a/md5.h
+++ b/md5.h
@@ -28,6 +28,10 @@
 
 #include "nettle-types.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /* Name mangling */
 #define md5_init nettle_md5_init
 #define md5_update nettle_md5_update
@@ -65,4 +69,8 @@ md5_digest(struct md5_ctx *ctx,
 void
 _nettle_md5_compress(uint32_t *state, const uint8_t *data);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* NETTLE_MD5_H_INCLUDED */
diff --git a/memxor.h b/memxor.h
index 5b43a99f9cc7266c8b71e8010d5bf09e9e23e473..c9e563d496be73fa5a5622f4aaf15cb2cfab0be7 100644
--- a/memxor.h
+++ b/memxor.h
@@ -8,7 +8,15 @@
 #include <stdlib.h>
 #include "nettle-types.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 uint8_t *memxor(uint8_t *dst, const uint8_t *src, size_t n);
 uint8_t *memxor3(uint8_t *dst, const uint8_t *a, const uint8_t *b, size_t n);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* NETTLE_MEMXOR_H_INCLUDED */
diff --git a/nettle-meta.h b/nettle-meta.h
index bcf5bd2a84358011eded63a9e3071c3f9a72e32a..05afb36f584b04d4cf9cd7376eee8cd6f04ffa00 100644
--- a/nettle-meta.h
+++ b/nettle-meta.h
@@ -28,6 +28,10 @@
 
 #include "nettle-types.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /* Randomness. Used by key generation and dsa signature creation. */
 typedef void (*nettle_random_func)(void *ctx,
 				   unsigned length, uint8_t *dst);
@@ -231,4 +235,8 @@ struct nettle_armor
 extern const struct nettle_armor nettle_base64;
 extern const struct nettle_armor nettle_base16;
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* NETTLE_META_H_INCLUDED */
diff --git a/nettle-types.h b/nettle-types.h
index a9d854ff74ad7c1ae83658d6da7bfc7591ecd22f..7b982517411eecf55477f344af72c171405231e2 100644
--- a/nettle-types.h
+++ b/nettle-types.h
@@ -25,6 +25,10 @@
 
 #include "nettle-stdint.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /* Uses a void * for cipher contexts.
 
    For block ciphers it would make sense with a const void * for the
@@ -37,5 +41,8 @@ typedef void (*nettle_crypt_func)(void *ctx,
 
 /* FIXME: Move more of the typedefs to this file? */
 
-#endif /* NETTLE_TYPES_H */
+#ifdef __cplusplus
+}
+#endif
 
+#endif /* NETTLE_TYPES_H */
diff --git a/pgp.h b/pgp.h
index 4b901a6d3b4b9541e1712a97fe46471864537210..fb3fdf5ba4ffa19ea653f468d826ae07085b1b10 100644
--- a/pgp.h
+++ b/pgp.h
@@ -34,6 +34,10 @@
    mpz_t defined. We don't do that here, in order to kludge through
    compilation without public key support and without gmp.h. */
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /* Name mangling */
 #define pgp_put_uint32 nettle_pgp_put_uint32
 #define pgp_put_uint16 nettle_pgp_put_uint16
@@ -232,4 +236,8 @@ enum pgp_subpacket_tag
     PGP_SUBPACKET_REASON_FOR_REVOCATION = 29,
   };
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* NETTLE_PGP_H_INCLUDED */
diff --git a/pkcs1.h b/pkcs1.h
index 29f06284f93c9960fdc9458555a111dcf0c6be1c..163c5dd31c1c411b55e5bd7b46c7fbff214ceeba 100644
--- a/pkcs1.h
+++ b/pkcs1.h
@@ -29,6 +29,10 @@
 #include <gmp.h>
 #include "nettle-types.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /* Name mangling */
 #define pkcs1_signature_prefix nettle_pkcs1_signature_prefix
 #define pkcs1_rsa_md5_encode nettle_pkcs1_rsa_md5_encode
@@ -57,4 +61,8 @@ pkcs1_rsa_sha1_encode(mpz_t m, unsigned length, struct sha1_ctx *hash);
 void
 pkcs1_rsa_sha1_encode_digest(mpz_t m, unsigned length, const uint8_t *digest);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* NETTLE_PKCS1_H_INCLUDED */
diff --git a/realloc.h b/realloc.h
index fcd4ca85c8dc07fe397f1d6f0ae6f3a11af7766f..c8c6aa4ce5d04ffce5400f621ee96be1a887584a 100644
--- a/realloc.h
+++ b/realloc.h
@@ -27,9 +27,17 @@
 
 #include "nettle-types.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 typedef void *nettle_realloc_func(void *ctx, void *p, unsigned length);
 
 nettle_realloc_func nettle_realloc;
 nettle_realloc_func nettle_xrealloc;
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* NETTLE_REALLOC_H_INCLUDED */
diff --git a/rsa-compat.h b/rsa-compat.h
index 7b40f3cf37c3477ab8264444afc5d84a50b7f5de..9622503d4c2d42f7f58a461f9c2304f0e1a0fb9a 100644
--- a/rsa-compat.h
+++ b/rsa-compat.h
@@ -28,6 +28,10 @@
 
 #include "rsa.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /* Name mangling */
 #define R_SignInit nettle_R_SignInit
 #define R_SignUpdate nettle_R_SignUpdate
@@ -120,6 +124,8 @@ R_VerifyFinal(R_SIGNATURE_CTX *ctx,
               unsigned length,
               R_RSA_PUBLIC_KEY *key);
 
+#ifdef __cplusplus
+}
+#endif
 
 #endif /* NETTLE_RSA_COMPAT_H_INCLUDED */
-
diff --git a/rsa.h b/rsa.h
index 4598d83e8b801d58c8dc2cbe02c28a401a30e45c..a4ea4de7ba24d600c622cb98975f05178c390dc7 100644
--- a/rsa.h
+++ b/rsa.h
@@ -35,6 +35,10 @@
 /* For nettle_random_func */
 #include "nettle-meta.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /* Name mangling */
 #define rsa_public_key_init nettle_rsa_public_key_init
 #define rsa_public_key_clear nettle_rsa_public_key_clear
@@ -324,4 +328,8 @@ _rsa_verify(const struct rsa_public_key *key,
 unsigned
 _rsa_check_size(mpz_t n);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* NETTLE_RSA_H_INCLUDED */
diff --git a/serpent.h b/serpent.h
index 4fb1d7d06e500dc8c603ee619e7ce4fd8cb7298c..2238f45b7453cf9d95fd3421f04259c3dcd0c4e7 100644
--- a/serpent.h
+++ b/serpent.h
@@ -33,6 +33,10 @@
 
 #include "nettle-types.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /* Name mangling */
 #define serpent_set_key nettle_serpent_set_key
 #define serpent_encrypt nettle_serpent_encrypt
@@ -70,4 +74,8 @@ serpent_decrypt(struct serpent_ctx *ctx,
                 unsigned length, uint8_t *dst,
                 const uint8_t *src);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* NETTLE_SERPENT_H_INCLUDED */
diff --git a/sexp.h b/sexp.h
index e85475924bf1b2bfeab60cfa9326fadfc57bd9ac..d8b39bf51218553eb291d87c7be90cc83b98f6b8 100644
--- a/sexp.h
+++ b/sexp.h
@@ -29,6 +29,10 @@
 #include <stdarg.h>
 #include "nettle-types.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /* Name mangling */
 #define sexp_iterator_first nettle_sexp_iterator_first
 #define sexp_transport_iterator_first nettle_sexp_transport_iterator_first
@@ -204,4 +208,8 @@ sexp_token_chars[0x80];
 
 #define TOKEN_CHAR(c) ((c) < 0x80 && sexp_token_chars[(c)])
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* NETTLE_SEXP_H_INCLUDED */
diff --git a/sha.h b/sha.h
index 30a531f47ca970154e3eff4de3a4b6e0b80f8d0f..22725d14756831eeee0ca54ae770e4c4e59c98e0 100644
--- a/sha.h
+++ b/sha.h
@@ -28,6 +28,10 @@
 
 #include "nettle-types.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /* Name mangling */
 #define sha1_init nettle_sha1_init
 #define sha1_update nettle_sha1_update
@@ -99,5 +103,8 @@ sha256_digest(struct sha256_ctx *ctx,
 	      unsigned length,
 	      uint8_t *digest);
 
+#ifdef __cplusplus
+}
+#endif
 
 #endif /* NETTLE_SHA_H_INCLUDED */
diff --git a/testsuite/testutils.h b/testsuite/testutils.h
index 7cc4b1fb68ce077daa5de22794d529f8ea171902..c69f7e3e7f5e2d93c50a7cb4df067201166a6c29 100644
--- a/testsuite/testutils.h
+++ b/testsuite/testutils.h
@@ -22,6 +22,10 @@
 
 #include "nettle-meta.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 void *
 xalloc(size_t size);
 
@@ -127,6 +131,10 @@ test_dsa_key(struct dsa_public_key *pub,
 
 #endif /* WITH_PUBLIC_KEY */
 
+#ifdef __cplusplus
+}
+#endif
+
 #define H2(d, s) decode_hex((d), (s))
 #define H(x) decode_hex_dup(x)
 #define HL(x) decode_hex_length(x), decode_hex_dup(x)
diff --git a/twofish.h b/twofish.h
index 9a1e9bab75fc13af13d62f00cbe19f3086c6325a..a21d0ec571e4cfc0da0bc366413a80140684a4a6 100644
--- a/twofish.h
+++ b/twofish.h
@@ -34,6 +34,10 @@
 
 #include "nettle-types.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /* Name mangling */
 #define twofish_set_key nettle_twofish_set_key
 #define twofish_encrypt nettle_twofish_encrypt
@@ -67,4 +71,8 @@ twofish_decrypt(struct twofish_ctx *ctx,
 		unsigned length, uint8_t *dst,
 		const uint8_t *src);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* NETTLE_TWOFISH_H_INCLUDED */
diff --git a/yarrow.h b/yarrow.h
index 36f8741e3c2b99a99b0ea199f1664f824aa8870b..52690bcf8fe37960b031c242ce0fcc5a343df03d 100644
--- a/yarrow.h
+++ b/yarrow.h
@@ -29,6 +29,10 @@
 #include "aes.h"
 #include "sha.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /* Name mangling */
 #define yarrow256_init nettle_yarrow256_init
 #define yarrow256_seed nettle_yarrow256_seed
@@ -120,4 +124,8 @@ unsigned
 yarrow_key_event_estimate(struct yarrow_key_event_ctx *ctx,
 			  unsigned key, unsigned time);
   
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* NETTLE_YARROW_COMPAT_H_INCLUDED */