Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ftw.h

Status
Not open for further replies.

wasson

Technical User
Mar 1, 2010
1
0
0
ES
Noob here.
gcc complains by stating:
warning: unused parameter ‘status’

1. I do not use stat, so how can I rewrite to omit it ?
2. Can it be rewritten so it can all be done in main rather than calling a function ?

Code:
int list(const char *filename, const struct stat *status, int type)
{
	if( (type == FTW_F) && strstr(filename, ".txt") )
	{
		puts(filename);
 	}

	return 0;
}

int main{
	ftw("path-to-folder", list, 1);

	return 0;
}
 
> 1. I do not use stat, so how can I rewrite to omit it ?
You can't.
It's part of the standard interface of ftw().

What you can do however is this:
Code:
int list(const char *filename, const struct stat *status [red]__attribute__ ((unused))[/red], int type)
{
    if( (type == FTW_F) && strstr(filename, ".txt") )
    {
        puts(filename);
     }

    return 0;
}
You still get the parameter, but it should stop the compiler complaining about it being unused.



--
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top