Simon
Simon

Reputation: 3

expected ')' before '*' token, can't seem to find error

So whenever I try to run my Makefile on my server, it always gives me the error is "Memory.c: 9 error: expected ')' before '*' token. But when I try to run it on my own computer, it works just fine. I've been trying to figure out what is wrong but can't seem to find it.

I've attached the 3 files that are used in this part of my program. Memory.c, Memory.h and ProcessInput.h.

This is Memory.c

/* Initializes memory */

#include <stdio.h>
#include <stdlib.h>

#include "memory.h"


void initializeMemory(memory** memArray, int memSize)
{
    // Allocating space for memory array
    *memArray = malloc(memSize * sizeof(memory));
    if(*memArray == NULL)
    {
        fprintf(stderr, "Error allocating space for array of memory" );
        exit(1); // exit(1) = Unsuccessful exit
    }

    // Initializing the contents within memory array
    int i = 0;
    for(i = 0; i < memSize; i ++)
    {
        ((*memArray)[i]).occupied = false;
    }
}

and this is Memory.h

// Definitions for Memory.c 

#define bool int
#define true 1
#define false 0

#include "ProcessInput.h"

// Include guards to prevent redefinition of struct
#ifndef MEMORY_H
#define MEMORY_H

typedef struct memoryDetail
{
    process process; 
    bool occupied;
} memory;

#endif

// Function declaration for memory.c
void initializeMemory(memory** memArray, int memSize);

the only thing used from ProcessInput.h is the process structure defined in ProcessInput.h

This is ProcessInput.h

// Include guards to prevent redefinition of struct
#ifndef PROCESSDETAIL_H
#define PROCESSDETAIL_H

typedef struct processDetail
{
    int timeCreated; 
    int processID; 
    int memorySize;
    int jobTime;
} process;

#endif

// function declarations for ProcessInput.c
void processInput(int* maxSize, int* count, process** processes, char* fileName);

I'm not too sure why it's giving me the error. I don't know where I'm supposed to be putting a missing right brace. Any advice is much appreciated!

edit: As informed, these are the following questions that I looked at but to not avail.

error: expected ‘)’ before ‘*’ token

Multiple of same error while compiling "error: expected ')' before '*' token

http://www.dreamincode.net/forums/topic/288956-error-expected-before-token/

thanks everyone for the help!

Upvotes: 0

Views: 730

Answers (2)

John3136
John3136

Reputation: 29265

#include "memory.h" is different to #include "Memory.h" (i.e. C is case sensitive)

If you tried #include "myfile.h" instead of #include "MyFile.h" the error may be more obvious. In this case it just happens that the compiler finds the system memory.h.

Upvotes: 1

AnT stands with Russia
AnT stands with Russia

Reputation: 320421

<memory.h> is a header from C library of pre-standard era. It is quite possible that your standard library still provides it and the compiler takes that one instead of yours.

Try renaming your header file and see if it changes anything.

Upvotes: 1

Related Questions