[cfe-dev] clang -cc1 error : file not found

Neil Semmel neil.semmel at gmail.com
Thu Mar 19 01:52:48 PDT 2015


Whoops, forgot to attach it to that email, but here [1] is a good reference
page about builtins.

Neil

[1] http://clang.llvm.org/docs/LibTooling.html#libtooling-builtin-includes

On Thu, Mar 19, 2015 at 4:51 AM, Neil Semmel <neil.semmel at gmail.com> wrote:

> Hello,
>
> The -cc1 flag is useful in some cases, but if you just want to print the
> ast, you can use the -Xclang switch as well. -cc1 will remove all builtin
> settings from clang, which includes standard defines, and standard include
> paths. -Xclang gives you access to the full set of clang flags for the next
> argument, it's like passing it to "clang -cc1" directly, but doesn't
> require all of the include paths etc to be set.
>
> $ clang -fsyntax-only -Xclang -ast-dump ./test.c
>
> or
>
> $ clang -Xclang -ast-dump -o test ./test.c
>
> when using -cc1, you must specify all include paths, and any other
> "normal" settings that clang would use for c/c++ compilation. If you do
>
> $ clang -v -o test ./test.c
>
> you should be able to see the full clang command with the -cc1 argument.
>
> But, since you're interested in dumping the ast, "-Xclang -ast-dump" is
> all you need.
>
> Neil
>
> On Thu, Mar 19, 2015 at 4:14 AM, 汪雷 <wangcppclei at gmail.com> wrote:
>
>> Hi, everyone!
>> I have a simple source file test.c,as follow:
>> ># include<stdio.h>
>> >int main() {
>> >  printf("Hello World\n");
>> >  return 0;
>> >}
>>
>> When I use command:$ clang test.c -o test .It's OK, and generate the test
>> executable.
>> But, when use command:$ clang test.c -cc1 test.c -o test  or
>> command:$clang -cc1 test.c -ast-print .Error occur.
>> :test.c:1:9: fatal error: 'stdio.h' file not found
>>
>> The office docments say that:"Users should not run clang -cc1 directly,
>> because -cc1 options are not guaranteed to be stable"  from:
>> http://clang.llvm.org/docs/FAQ.html
>> Now I want to print the ast..
>> The platform is ubuntu14.04, LLVM version is 3.6, the same to 3.5.
>> I want to print the ast. Is there anyone can help me? Thinks very much^.^
>>
>> _______________________________________________
>> 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/20150319/bb0855f5/attachment.html>


More information about the cfe-dev mailing list