Skip to content

Instantly share code, notes, and snippets.

@wobbol
Last active January 30, 2018 19:20
Show Gist options
  • Save wobbol/a7c316962dafd7d9fef123d4887b9efa to your computer and use it in GitHub Desktop.
Save wobbol/a7c316962dafd7d9fef123d4887b9efa to your computer and use it in GitHub Desktop.
Why do I get warnings when I do this?
#include <stdarg.h>
#include <string.h>
#include <dirent.h>
#include <stdlib.h>
#include <stdio.h>
int min_example(const struct dirent *ent, char *string)
{
static const char *s = NULL;
if(string) {
s = string;
return 0;
} else if(!s) {
return 0;
}
return !strcmp(ent->d_name, s);
}
int shim(const struct dirent *ent)
{
return min_example(ent, NULL);
}
void main(void)
{
struct dirent **ent;
min_example(NULL, "afile");
int n = scandir(".", &ent, shim, NULL); /* Error on function min_example not matching. */
while(n--){
printf("%s\n", ent[n]->d_name);
free(ent[n]);
}
free(ent);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment