So I have a header file and 2 .c files within the beginnings of my program. I go to compile and I get the error message (tons of these over and over)
command_parser.c:74:6: error: static declaration of ‘read_args_file’ follows non-static declaration
command_parser.h:9:6: note: previous declaration of ‘read_args_file’ was here
Now I do not use the static keyword ANYWHERE in my program...so why would GCC go and think that I've declared a static function???
Below is the relevant code for read_args_file's declaration in the .h and .c files:
void read_args_file(char* file_name, char* out_file_name, int (*command_read)(char* command, FILE* out));
void read_args_file(char* file_name, char* out_file_name, int (*command_read)(char* command, FILE* out)) {
.....
}
EDIT:
The entire .h file is:
#ifndef COMMAND_PARSER_H_
#define COMMAND_PARSER_H_
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
/* line 8 follows: */
void switch_parsing(int argc, char* argv[], int (*command_read)(char* command, FILE* out), char* (*pr int_usage)()) {
void read_args_file(char* file_name, char* out_file_name, int (*command_read)(char* command, FILE* ou t));
void read_args_input(int (*command_read)(char* command, FILE* out));
#endif
The command_parser.c file until the function definition is:
void switch_parsing(int argc, char* argv[], int (*command_read)(char* command, FILE* out), char* (*print_usage)()) {
char* arg;
char* return_string;
char* wrong_string = "Please enter either -i, -h, or -f as a switch. Use -h for help.\n";
char* invalid_f_args = "You entered an invalid number of arguments for the -f switch! Only two are permitted, <commands_file> and <output_file>.\n";
int str_len = 0;
char cur;
if (argc > 1) {
arg = argv[1];
}
else {
arg = "\0";
}
str_len = strlen(arg);
if (str_len == 2) {
if (arg[0] == '-') {
cur = arg[1];
if (cur == 'i') {
read_args_input(command_read);
return_string = "";
}
else if (cur == 'f') {
if (argc == 4) {
read_args_file(argv[2], argv[3], (*command_read));
return_string = "";
}
else {
return_string = invalid_f_args;
}
}
else if (cur == 'h') {
return_string = print_usage();
}
else {
return_string = "The switch ";
return_string = strcat(return_string, &cur);
return_string = strcat(return_string, " is an invalid switch.\n");
}
}
}
else if (str_len == 1) {
return_string = wrong_string;
}
else if (str_len > 2) {
return_string = wrong_string;
}
else if (str_len == 0) {
return_string = print_usage();
}
else {
return_string = wrong_string;
}
}
/**
* Reads arguments from a passed in file name, and writes the output from the commands
* in the file to the out_file_name. Arguments are run through command_read function
* passed in to be executed.
*/
/* line 74 follows: */
void read_args_file(char* file_name, char* out_file_name, int (*command_read)(char* command, FILE* out)) {