Hello Julia, Thank you very much. It is not a big problem to have to use -macro_file. We would like the script to be fully self-contained, but it's not a hard requirement. If there is no way around it, then that's fine. I am very new to Coccinelle and wanted to check if there is a better solution than the one I found.
Regards, Tammy -----Original Message----- From: Julia Lawall [mailto:[email protected]] Sent: Friday, February 18, 2011 3:15 PM To: Leino, Tammy Cc: [email protected] Subject: Re: [Cocci] Header files in scripts On Fri, 18 Feb 2011, Leino, Tammy wrote: > Hello, > > > > I am having to use the -macro-file command line option to get my script > to operate properly. This is because when parsing the file, the > Coccinelle script is unable to find the header file in the source tree > that already contains the macro needed by the C code it is parsing. I > am therefore having to redefine the macro in another file to be used > with -macro-file. Is there a way to point the script to the header > files that the C code requires? I have tried -I, but it still can't > find the macro. > > > > The macro is MCAPI_THREAD_ENTRY, and is being used to define a thread > as follows: > > > > #define MCAPI_THREAD_ENTRY(f) void *f(void *argv) > > > > So instead of declaring void *MCAPI_FTS_Tx_2_35_1(void *argv) in the > source code (which is not portable across operating systems that don't > use the same definition for a thread), we use > MCAPI_THREAD_ENTRY(MCAPI_FTS_Tx_2_35_1). To port to other operating > systems, just set MCAPI_THREAD_ENTRY to the properly definition. > > > > If I don't use the -macro-file option to declare the macro, Coccinelle > rejects MCAPI_THREAD_ENTRY. Is it a problem to use the -macro_file option? The problem is not that Coccinelle doesn't find the .h file, but that it doesn't do much with the information it contains. To my recollection, it does make some effort to use it in one of theparsing passes, but probably not in the case you describe. julia _______________________________________________ Cocci mailing list [email protected] http://lists.diku.dk/mailman/listinfo/cocci (Web access from inside DIKUs LAN only)
