diff --git a/3rdparty/include/opencl/1.2/CL/cl.hpp b/3rdparty/include/opencl/1.2/CL/cl.hpp
index 0480e3116..2502d4c52 100644
--- a/3rdparty/include/opencl/1.2/CL/cl.hpp
+++ b/3rdparty/include/opencl/1.2/CL/cl.hpp
@@ -210,7 +210,7 @@
 #include <string>
 #endif 
 
-#if defined(linux) || defined(__APPLE__) || defined(__MACOSX)
+#if defined(__linux__) || defined(__APPLE__) || defined(__MACOSX)
 #include <alloca.h>
 
 #include <emmintrin.h>
diff --git a/modules/ocl/src/cl_runtime/cl_runtime.cpp b/modules/ocl/src/cl_runtime/cl_runtime.cpp
index a0d967c0b..c3a31ccc3 100644
--- a/modules/ocl/src/cl_runtime/cl_runtime.cpp
+++ b/modules/ocl/src/cl_runtime/cl_runtime.cpp
@@ -45,7 +45,7 @@
     #define CV_CL_GET_PROC_ADDRESS(name) WinGetProcAddress(name)
 #endif // _WIN32
 
-#if defined(linux)
+#if defined(__linux__)
     #include <dlfcn.h>
     #include <stdio.h>
 
diff --git a/modules/ocl/src/cl_runtime/clamdblas_runtime.cpp b/modules/ocl/src/cl_runtime/clamdblas_runtime.cpp
index 0a077db69..1256000c8 100644
--- a/modules/ocl/src/cl_runtime/clamdblas_runtime.cpp
+++ b/modules/ocl/src/cl_runtime/clamdblas_runtime.cpp
@@ -27,7 +27,7 @@
     #define CV_CL_GET_PROC_ADDRESS(name) WinGetProcAddress(name)
 #endif // _WIN32
 
-#if defined(linux)
+#if defined(__linux__)
     #include <dlfcn.h>
     #include <stdio.h>
 
diff --git a/modules/ocl/src/cl_runtime/clamdfft_runtime.cpp b/modules/ocl/src/cl_runtime/clamdfft_runtime.cpp
index 60cbecef2..f0fa769b7 100644
--- a/modules/ocl/src/cl_runtime/clamdfft_runtime.cpp
+++ b/modules/ocl/src/cl_runtime/clamdfft_runtime.cpp
@@ -27,7 +27,7 @@
     #define CV_CL_GET_PROC_ADDRESS(name) WinGetProcAddress(name)
 #endif // _WIN32
 
-#if defined(linux)
+#if defined(__linux__)
     #include <dlfcn.h>
     #include <stdio.h>
 
diff --git a/modules/ocl/src/cl_runtime/generator/template/clamdblas_runtime.cpp.in b/modules/ocl/src/cl_runtime/generator/template/clamdblas_runtime.cpp.in
index 8492edda9..0cf33bb7e 100644
--- a/modules/ocl/src/cl_runtime/generator/template/clamdblas_runtime.cpp.in
+++ b/modules/ocl/src/cl_runtime/generator/template/clamdblas_runtime.cpp.in
@@ -24,7 +24,7 @@
     #define CV_CL_GET_PROC_ADDRESS(name) WinGetProcAddress(name)
 #endif // _WIN32
 
-#if defined(linux)
+#if defined(__linux__)
     #include <dlfcn.h>
     #include <stdio.h>
 
diff --git a/modules/ocl/src/cl_runtime/generator/template/clamdfft_runtime.cpp.in b/modules/ocl/src/cl_runtime/generator/template/clamdfft_runtime.cpp.in
index aee6bd8ab..8e8fb42c4 100644
--- a/modules/ocl/src/cl_runtime/generator/template/clamdfft_runtime.cpp.in
+++ b/modules/ocl/src/cl_runtime/generator/template/clamdfft_runtime.cpp.in
@@ -24,7 +24,7 @@
     #define CV_CL_GET_PROC_ADDRESS(name) WinGetProcAddress(name)
 #endif // _WIN32
 
-#if defined(linux)
+#if defined(__linux__)
     #include <dlfcn.h>
     #include <stdio.h>