[cfe-dev] Question: how to robustly detect available command line arguments

david.cole david.cole at kitware.com
Mon Jun 4 11:29:13 PDT 2012

I'm one of the CMake developers. We have an issue in our bug tracker that's
related to clang's command line argument parsing:

The bug reported is using this version of clang (MacOS X 10.7.3 with Xcode
$ /usr/bin/cc -v
Apple clang version 3.1 (tags/Apple/clang-318.0.58) (based on LLVM 3.1svn)

In the bug report, the CMake script code is trying to run clang to test if
it recognizes a given command line argument. We expect to report that it
does not support an argument if there's an error when using the argument
trying to compile this snippet: "int main() { return 0;}"

When given "-maltivec" it produces:
clang: warning: argument unused during compilation: '-maltivec'

By giving us that output, clang indicates that it does recognize the -m
compiler argument, but warns us that -maltivec has not been used. (At least,
that's how I read it.)

So, here's the question: Can you recommend how to robustly detect whether or
not clang supports a given command line argument? For both existing versions
of clang in the wild, and future releases.

The bug reporter in this case, wants us to recognize "argument unused during
compilation" as an error, but I'm concerned that doing so will falsely
report other valid command line arguments as unavailable...

David Cole
Kitware, Inc.

View this message in context: http://clang-developers.42468.n3.nabble.com/Question-how-to-robustly-detect-available-command-line-arguments-tp4024269.html
Sent from the Clang Developers mailing list archive at Nabble.com.

More information about the cfe-dev mailing list