[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

problemi con make



Ciao a tutti, ho appena installato la debian woody3.0r5, installando solo i pacchetti base, e sto cercando di sistemarla piano piano.. e dato che ho bisogno di programmare, ho provato a compilare un programma ma ottengo questi errori:

shell_util.c: In function `trim':
shell_util.c:13: parse error before `char'
shell_util.c:14: `end' undeclared (first use in this function)
shell_util.c:14: (Each undeclared identifier is reported only once
shell_util.c:14: for each function it appears in.)
shell_util.c: In function `parse_command_line':
shell_util.c:37: parse error before `int'
shell_util.c:39: `i' undeclared (first use in this function)
make: *** [shell_util.o] Error 1

e queste sono le righe che danno errore:
#include <ctype.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "shell_util.h"

// s[3]  ==  *(s + 3)

char * trim(char * s) {
 char *begin = s;
 while (isspace(*begin)) begin++;

 char *end = begin + (strlen(begin)-1);
 while (end > begin && isspace(*end)) {
   *end  = '\0';
   end--;
 }
 return begin;
}

#define MAX_ARGS 100
#define MAX_LINE 1000
char ** parse_command_line(char *line) {
 static char * args[MAX_ARGS];
 char * delim = " \t\n";
 char * token;

 char buf[MAX_LINE];
 strcpy(buf, line);
   //  while(*buf == ' ')
    // buf++;

 args[0] = strdup(strtok(line, delim));

 if (NULL == args[0]) return args;
 int i = 1;
 while (NULL != (token = strtok(NULL, delim))) {
   args[i] = strdup(token);
   i++;
 }
 args[i] = NULL;
 return args;
}

**********************************

sono sicuro che il codice sia corretto, perchè sulla slackware compila senza problemi, quindi immagino sia così perchè manchi qualche libreria.. voi sapete dirmi cosa dovrei fare??

Grazie, ciao
---------------
carlito's way




Reply to: