How to dump ast of a objective-c file correctly?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

How to dump ast of a objective-c file correctly?

David Chisnall via cfe-dev
I try to dump ast for a .m in a test folder(just a single source file, no project file). I use the command “clang -x objective-c -Xclang -ast-dump -fobjc-arc main.m”. when I write some number literals(@(2)) or  array literals (@[@“1”]), the command will report a error “error: definition of class NSArray must be available to use Objective-C array literals”, anyone know how to fix this?

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: How to dump ast of a objective-c file correctly?

David Chisnall via cfe-dev


Le 11 nov. 2017 à 05:50, Karl Peng via cfe-dev <[hidden email]> a écrit :

I try to dump ast for a .m in a test folder(just a single source file, no project file). I use the command “clang -x objective-c -Xclang -ast-dump -fobjc-arc main.m”. when I write some number literals(@(2)) or  array literals (@[@“1”]), the command will report a error “error: definition of class NSArray must be available to use Objective-C array literals”, anyone know how to fix this?

Yes, you must import NSArray.h, NSNumber.h etc. in your main.m file. This is usually done by using #import <Foundation/Foundation.h>




_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev