diff --git a/lib/bitop/CMakeLists.txt b/lib/bitop/CMakeLists.txt
index 02e8a421d..80b627446 100644
--- a/lib/bitop/CMakeLists.txt
+++ b/lib/bitop/CMakeLists.txt
@@ -1,4 +1,4 @@
-add_library(bitop STATIC bit.c)
+add_library(bitop STATIC bit.cpp)
 target_link_libraries(bitop)
 
 include_directories(${LUA_INCLUDE_DIR})
diff --git a/lib/bitop/bit.c b/lib/bitop/bit.cpp
similarity index 99%
rename from lib/bitop/bit.c
rename to lib/bitop/bit.cpp
index f23c31a4c..39b53838f 100644
--- a/lib/bitop/bit.c
+++ b/lib/bitop/bit.cpp
@@ -26,12 +26,16 @@
 ** [ MIT license: http://www.opensource.org/licenses/mit-license.php ]
 */
 
+extern "C" {
 #include "bit.h"
+}
 
 #define LUA_BITOP_VERSION	"1.0.2"
 
 #define LUA_LIB
+extern "C" {
 #include "lauxlib.h"
+}
 
 #ifdef _MSC_VER
 /* MSVC is stuck in the last century and doesn't have C99's stdint.h. */