title: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
body: <p>I am working on a simple shell project and i had the main loop working. I could input commands and it would parse the string.  I also had a which command working.  I made some small changes and now i get the error:</p>
  
  <pre><code>sh.c: In function ‘which’:
  sh.c:15: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
  sh.c:85: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
  sh.c:92: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
  sh.c:97: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
  sh.h:6: error: old-style parameter declarations in prototyped function definition
  sh.c:100: error: expected ‘{’ at end of input
  make: *** [sh.o] Error 1
  </code></pre>
  
  <p>Below is my sh.c file. I tried entirely removing my which code because i though that was the issue. But it changed nothing.</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;string.h&gt;
  #include &lt;strings.h&gt;
  #include &lt;limits.h&gt;
  #include &lt;unistd.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;pwd.h&gt;
  #include &lt;dirent.h&gt;
  #include &lt;sys/types.h&gt;
  #include &lt;sys/wait.h&gt;
  #include &lt;signal.h&gt;
  #include "sh.h"
  
  int sh( int argc, char **argv, char **envp )
  {
    char *prompt = calloc(PROMPTMAX, sizeof(char));
    char *commandline = calloc(MAX_CANON, sizeof(char));
    char *command, *arg, *commandpath, *p, *pwd, *owd;
    char **args = calloc(MAXARGS, sizeof(char*));
    int uid, i, status, argsct, go = 1;
    struct passwd *password_entry;
    char *homedir;
    struct pathelement *pathlist;
  
    uid = getuid();
    password_entry = getpwuid(uid);               /* get passwd info */
    homedir = password_entry-&gt;pw_dir;     /* Home directory to startout with*/
  
    if ( (pwd = getcwd(NULL, PATH_MAX+1)) == NULL )
    {
      perror("getcwd");
      exit(2);
    }
    owd = calloc(strlen(pwd) + 1, sizeof(char));
    memcpy(owd, pwd, strlen(pwd));
    prompt[0] = ' '; 
    prompt[1] = '\0';
  
    /* Put PATH into a linked list */
    pathlist = get_path();
  
    while ( go )
    {
      /* print your prompt */
      printf(" [%s]&gt;", getcwd(NULL, PATH_MAX+1));
      /* get command line and process */
        fgets(commandline, MAX_CANON, stdin);
  
      printf("in commandline %s", commandline);
  
      args[0] = strtok(commandline, " \n");
      int n = 0;
      printf ("in args %s;\n", args[0]);
      while(args[n]!=NULL){
        n++;
        args[n] = strtok(NULL, " \n");
        printf ("in args %s;\n", args[n]);
      }
  
  
  
      /* check for each built in command and implement */
      if(strcmp(args[0], "exit") == 0){
        printf("exiting\n");
        exit(0);
      }
  
      if(strcmp(args[0], "which") == 0){
        which(args, pathlist);
  
      }
  
    }
    return 0;
  } /* sh() */
  
  int which(char **args, struct pathelement *pathlist )
  {
    return 0;
  }
  
  
  
  char *where(char *command, struct pathelement *pathlist )
  {
    /* similarly loop through finding all locations of command */
  } /* where() */
  
  void list ( char *dir )
  {
    /* see man page for opendir() and readdir() and print out filenames for
    the directory passed */
  } /* list() */
  </code></pre>
  
  <p>Below is my sh.h file</p>
  
  <pre><code>#include "get_path.h"
  
  int pid;
  int sh( int argc, char **argv, char **envp);
  int which(char **args, struct pathelement *pathlist )
  char *where(char *command, struct pathelement *pathlist);
  void list ( char *dir );
  void printenv(char **envp);
  
  #define PROMPTMAX 32
  #define MAXARGS 10
  </code></pre>
  
  <p>I know it is probably some silly mistake like missing a semicolon or a bracket.  But I've gone through all of the code a few times and can't seem to find it.</p>