views:

46

answers:

3

Say you have a C project with tons of files, and tons of configurations managed by usign the -D option in GCC to define some flags.

In my particular case, I have loads of files with that kind of stuff:

void foo( sometype *x)
{
   do_stuff_with_x(x);

#ifdef MY_FLAG
   do_additional_stuff(x);
#endif

#ifdef OTHER_FLAG
   do_some_other_stuff(x);
#endif

}

Now, whenever I change one of the flags, I need to clear the project and recompile all the source code because I cannot selectively touch the files that use this flag.

Is it possible, using Eclipse under Windows, to do that? Maybe an Eclipse plugins, or whatever.

For linux, I might use some mix of grep, find and touch, but on Windows I have no idea.

A: 

If you have already cooked up a solution for Unix with grep, find and touch, why don't you do the same on Windows? You can use msys and the unix tools that come with it.

I don't have an Eclipse installation on the machine I am at the moment, but I'm sure you can launch a batch from Eclipse

Remo.D
`find . -name "*.c" | xargs grep "MYFLAG" -q -l | xargs touch` does the trick, but, well, I hoped to see smething similar in Windows.
Gui13
A: 

Why wouldn't you use a mix of grep, find, and touch on Windows too?

http://unxutils.sourceforge.net/

jamesdlin
+1  A: 

Okay, under people pressure, I installed MSYS and used a command like this one:

$ find . -name "*.c" -or -name "*.h" | xargs grep "MYFLAG" -q -l | xargs touch

You can actually add some other filters to find to tune more finely your touched files.

I didn't know xargs, any idead on my command line?

Gui13
You should probably use find's -print0 and xargs -0 options to avoid possible bugs if there are filenames with spaces or newlines.
Hudson