Discussion:
Macro to select c++ as default compiler for c files
Lakshmi M
2014-11-03 10:32:35 UTC
Permalink
Hi All,

I am working with autotools and i wish to use c++ compiler by default
for compiling my c files.

USUAL behaviour :
ex : myexecutable_SOURCES = file.cpp -> uses c++ compiler
myexecutable_SOURCES = file.c -> uses c compiler
(myexecutable_SOURCES is defined in my Makefile.am)

Expected behaviour :
ex : myexecutable_SOURCES = file.cpp -> uses c++ compiler
myexecutable_SOURCES = file.c -> SHOULD USE c++ compiler
(myexecutable_SOURCES is defined in my Makefile.am)

I tried using AC_PROG_CC([c++]) and AC_LANG([C++]) in my configure.ac
but its still using c compiler.

Can anyone please let me know how to use c++ compiler as default for
compiling my c files.

Thanks & Regards,
Lakshmi M
Zack Weinberg
2014-11-03 14:33:30 UTC
Permalink
Why can't you just rename the `.c` files to `.cpp`? If you want to
compile them with a C++ compiler then they *are* C++.
Post by Lakshmi M
Hi All,
I am working with autotools and i wish to use c++ compiler by default for
compiling my c files.
ex : myexecutable_SOURCES = file.cpp -> uses c++ compiler
myexecutable_SOURCES = file.c -> uses c compiler
(myexecutable_SOURCES is defined in my Makefile.am)
ex : myexecutable_SOURCES = file.cpp -> uses c++ compiler
myexecutable_SOURCES = file.c -> SHOULD USE c++ compiler
(myexecutable_SOURCES is defined in my Makefile.am)
I tried using AC_PROG_CC([c++]) and AC_LANG([C++]) in my configure.ac but
its still using c compiler.
Can anyone please let me know how to use c++ compiler as default for
compiling my c files.
Thanks & Regards,
Lakshmi M
_______________________________________________
Autoconf mailing list
https://lists.gnu.org/mailman/listinfo/autoconf
Loading...