diff --git a/configure b/configure
index b97a4eea9ade1f1f3ff51e3ed5718befb256970b..3d91d2a244aea09b7514eba5c722282a5efb8b37 100755
--- a/configure
+++ b/configure
@@ -990,7 +990,7 @@ echo "configure:989: checking ansi standard C++ stream headers " >&5
   cat > conftest.cc <<!
 #include <iostream>
 !
-  if test -z "`${CXX} $CMAKE_ANSI_CFLAGS $CXXFLAGS $CPPFLAGS  -c conftest.cc 2>&1`"; then
+  if test -z "`${CXX} $CMAKE_ANSI_CXXFLAGS $CXXFLAGS $CPPFLAGS  -c conftest.cc 2>&1`"; then
     echo "$ac_t""yes" 1>&6
   else
     cat >> confdefs.h <<\EOF
@@ -1010,7 +1010,7 @@ echo "configure:1008: checking ansi standard namespace support " >&5
 #include <list>
 void foo() { std::list<int> l; }
 !
-  if test -z "`${CXX} $CMAKE_ANSI_CFLAGS $CXXFLAGS $CPPFLAGS -c conftest.cc 2>&1`"; then
+  if test -z "`${CXX} $CMAKE_ANSI_CXXFLAGS $CXXFLAGS $CPPFLAGS -c conftest.cc 2>&1`"; then
     echo "$ac_t""yes" 1>&6
   else
     cat >> confdefs.h <<\EOF
@@ -1029,7 +1029,7 @@ echo "configure:1028: checking ansi for scope support " >&5
   cat > conftest.cc <<!
 void foo() { for(int i;;); for(int i;;); }
 !
-  if test -z "`${CXX} $CMAKE_ANSI_CFLAGS $CXXFLAGS $CPPFLAGS -c conftest.cc 2>&1`"; then
+  if test -z "`${CXX} $CMAKE_ANSI_CXXFLAGS $CXXFLAGS $CPPFLAGS -c conftest.cc 2>&1`"; then
     echo "$ac_t""yes" 1>&6
   else
     cat >> confdefs.h <<\EOF
diff --git a/configure.in b/configure.in
index 77546fb2978c97901b6c55c1780239cd3d308c9b..027a341f3a3aa3227e667fe680a61d8e7ee65497 100644
--- a/configure.in
+++ b/configure.in
@@ -104,7 +104,7 @@ if test $ac_cv_prog_gxx = no; then
   cat > conftest.cc <<!
 #include <iostream>
 !
-  if test -z "`${CXX} $CMAKE_ANSI_CFLAGS $CXXFLAGS $CPPFLAGS  -c conftest.cc 2>&1`"; then
+  if test -z "`${CXX} $CMAKE_ANSI_CXXFLAGS $CXXFLAGS $CPPFLAGS  -c conftest.cc 2>&1`"; then
     echo "$ac_t""yes" 1>&6
   else
     AC_DEFINE(CMAKE_NO_ANSI_STREAM_HEADERS)
@@ -120,7 +120,7 @@ if test $ac_cv_prog_gxx = no; then
 #include <list>
 void foo() { std::list<int> l; }
 !
-  if test -z "`${CXX} $CMAKE_ANSI_CFLAGS $CXXFLAGS $CPPFLAGS -c conftest.cc 2>&1`"; then
+  if test -z "`${CXX} $CMAKE_ANSI_CXXFLAGS $CXXFLAGS $CPPFLAGS -c conftest.cc 2>&1`"; then
     echo "$ac_t""yes" 1>&6
   else
     AC_DEFINE(CMAKE_NO_STD_NAMESPACE)
@@ -135,7 +135,7 @@ if test $ac_cv_prog_gxx = no; then
   cat > conftest.cc <<!
 void foo() { for(int i;;); for(int i;;); }
 !
-  if test -z "`${CXX} $CMAKE_ANSI_CFLAGS $CXXFLAGS $CPPFLAGS -c conftest.cc 2>&1`"; then
+  if test -z "`${CXX} $CMAKE_ANSI_CXXFLAGS $CXXFLAGS $CPPFLAGS -c conftest.cc 2>&1`"; then
     echo "$ac_t""yes" 1>&6
   else
     AC_DEFINE(CMAKE_NO_ANSI_FOR_SCOPE)