Last active
January 30, 2018 19:20
-
-
Save wobbol/a7c316962dafd7d9fef123d4887b9efa to your computer and use it in GitHub Desktop.
Why do I get warnings when I do this?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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