I've looked at a lot of posts on stack regarding this question. It is almost always a simple semi-colon error, or parentheses/bracket mismatches. I do not believe this to be the case with my program however. I have a problem with this particular function:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <errno.h>
#include <unistd.h>
#include <sys/wait.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/time.h>
static char *macro_buf;
static unsigned int macro_buf_len;
static char *init_buf() {
if (macro_buf == 0) {
macro_buf_len = 200;
macro_buf = (char *) malloc(sizeof(char) * macro_buf_len);
macro_buf[0] = '\0';
}
return macro_buf;
}
The error reports the first line of the function definition. What is interesting is if I remove this function, everything compiles fine and runs normally! I've checked for any special invisible characters, I have re-wrote it a few times to no avail. Is there something obvious that I am missing?
EDIT: After changing the name of my function, all is well. I want to assume this might be a function already defined in one of my header files?
EDIT: I forgot I was using a macro with the same name.
#define init_buf....
Thanks guys! This is my first project over 1000 lines and its getting very tough to manage. I will not forget this error now though!