> I don't know if moving to .cpp is safe everywhere. Hence this patch.
VC++ understands an option `-Tp' (or `-TP') that tells the file is a C++
file no matter what its extension is. `-Tp' must be followed by the
file name immediately (as in `-Tpfoo.cxx', no space allowed), `-TP'
applies to all source files on the command line. Another alternative is
to hack with the registry. In any case, `-o' must be switched to `-Fo'.
The other alternative is to dynamically check whether the compiler is
the Microsoft one. The build system I maintain (it uses autoconf) does
something like the below.
dnl
+++###################################################################
dnl Deal with Microsoft compilers.
dnl
AC_DEFUN(AC_PROG_CC,
[
dnl We can end up with a Microsoft compiler only if the `$CC' was set
before
dnl we get here; otherwise we'll just choose something else. So check
this
dnl first here, and then just use the original definition.
srt_cmd="`echo \"$CC\" | sed 's%-nologo%%'`";;
srt_out="`${srt_cmd-cc} 2>&1 | head -1 | grep '^Microsoft'`"
if test -n "$srt_out"; then
srt_c_out="-Fo"
fi
SRT_AC_PROG_CC])dnl
dnl
---###################################################################
dnl
+++###################################################################
dnl Deal with Microsoft compilers.
dnl
AC_DEFUN(AC_PROG_CXX,
[
dnl We can end up with a Microsoft compiler only if the `$CXX' was set
before
dnl we get here; otherwise we'll just choose something else. So check
this
dnl first here, and then just use the original definition.
srt_cmd="`echo \"$CXX\" | sed 's%-nologo%%'`"
srt_out="`${srt_cmd-g++} 2>&1 | head -1 | grep '^Microsoft'`"
if test -n "$srt_out"; then
srt_cxx_ext="cpp"
srt_cxx_out="-Fo"
fi
SRT_AC_PROG_CXX])dnl
dnl
---###################################################################
SRT_AC_* are the autoconf definitions of the corresponding macros. The
AC_LANG_* macros have redefinitions that use the srt_* variables instead
of the ac_* ones (they also do a complete switch of LIBS and LDFLAGS
across languanges, but that's another story). Note that this build
system knows exactly the compilers and libraries and simply tells
autoconf what values to use (by setting the environment variables).
autoconf is not allowed to do any substantial guessing on the compilers.
That's C and C++. Then there is of course the `df' Windows FORTRAN
compiler that has, well, very interesting properties :-) Interesting
enough that you should probably not even consider supporting it in
autoconf (this build system only supports it in the make environment,
not in autoconf).
Cheers,
//lat
--
It is better to light one small candle than to curse the darkness.
--Eleanor Roosevelt