[cfe-dev] Clang: template functions

Stefano S kindoblue at gmail.com
Fri Nov 5 07:05:03 PDT 2010


Hi,

I'm not compiling the header directly, it is included in another header,
which is included in a *.cpp file. So, the extension should be interpreted
as signaling a c++ source, right? What I did was basically

export CC=cflags
export CXX=cflags++
export CPP=cflags++

and then running the configure phase followed by a compilation phase. It
really seems the C and not C++ mode is working here but I wonder why is
that. Anyway, thanks a lot for the replies

Regards,
Stefano



On Fri, Nov 5, 2010 at 12:56 PM, Sebastian Redl <
sebastian.redl at getdesigned.at> wrote:

> On 05.11.2010 12:27, Frits van Bommel wrote:
> > On Fri, Nov 5, 2010 at 12:15 PM, Sebastian Redl
> > <sebastian.redl at getdesigned.at>  wrote:
> >> Sounds like you're trying to compile C++ code as C. Just because you
> >> invoke Clang as clang++ doesn't mean it runs in C++ mode, it only means
> >> it will link against the C++ runtime libraries. To actually compile in
> >> C++ mode, the file must have a C++ extension (.cxx, .cpp or .cc), or you
> >> have to override the language detection with the -x option.
> > It does, actually. From clang/tools/driver/driver.cpp:
> >
> >    // Check for ".*++" or ".*++-[^-]*" to determine if we are a C++
> >    // compiler. This matches things like "c++", "clang++", and
> "clang++-1.1".
> >    //
> >    // Note that we intentionally want to use argv[0] here, to support
> "clang++"
> >    // being a symlink.
> >    //
> >    // We use *argv instead of argv[0] to work around a bogus g++ warning.
> >    const char *progname = argv_[0];
> >    std::string ProgName(llvm::sys::Path(progname).getBasename());
> >    if (llvm::StringRef(ProgName).endswith("++") ||
> >        llvm::StringRef(ProgName).rsplit('-').first.endswith("++")) {
> >      TheDriver.CCCIsCXX = true;
> >    }
> That still doesn't mean that it will automatically use C++ as the input
> language. It might mean that it interprets .h files differently.
>
> Sebastian
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20101105/dee0cea4/attachment.html>


More information about the cfe-dev mailing list