Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8738575
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T10:45:41+00:00 2026-06-13T10:45:41+00:00

So I have a header file and 2 .c files within the beginnings of

  • 0

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)) {
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T10:45:42+00:00Added an answer on June 13, 2026 at 10:45 am

    There is a brace open in the .h file line 8: void switch_parsing(int argc, ..... ){

    The lines that follow are treated by the compile as one big function body, and the final error will be found after the compiler fails to find a matching ‘}’. Many lines (and files) later. The OP got lucky: the compiler first found another (semantic) error.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have registered an enumeration type ClefType within my header file - this enum
I have three files: movie.h (header); movie.cpp (implementation file); lab9.cpp (driver file using movie
I have a header file buildTree.h and a C file buildTree.c there is a
I have a header file like this: #ifndef __GEN_NOTE_MARKERS_TO_DEVELOPERS_HPP__ #define __GEN_NOTE_MARKERS_TO_DEVELOPERS_HPP__ #ifdef _DEBUG //
I have a header file, lets say Common.h, that is included in all of
I have a header file variable.h where i declare all my global variable.Then i
I have C header file containing the following type definition: // example.h typedef struct
I have a header file with all the enums listed (#ifndef #define #endif construct
I have this header file, zeeheader.h, and I wrote some classes in it, I'm
I have a header file. In this header I want to use a map

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.