0

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!

Community
  • 1
  • 1
Simon
  • 3
  • 2
  • Just to add, I've tried looking through other questions on Stack Overflow from people experiencing the same issues but the provided solution to each question is already done by me. – Simon Apr 06 '16 at 00:58
  • You should edit your question to include a list of the questions you found to help prevent it from being closed as a duplicate. – skrrgwasme Apr 06 '16 at 01:02
  • Is the server running Linux and your computer Windows? – user253751 Apr 06 '16 at 01:06
  • Yes it is running Linux. John3136's solution worked for me. A minor hindsight on my part when I went to rename my files. Thanks all the help everyone! – Simon Apr 06 '16 at 04:55

2 Answers2

1

<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.

AnT stands with Russia
  • 312,472
  • 42
  • 525
  • 765
1

#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.

John3136
  • 28,809
  • 4
  • 51
  • 69
  • Is C case sensitive? I thought it was a platform-specific thing, and Unixes are, and Windows isn't. – user253751 Apr 06 '16 at 01:06
  • @immibis - you're right http://stackoverflow.com/questions/1951951/when-including-header-files-is-the-path-case-sensitive I still think this is the answer given that we're working on one computer and not another ;-) – John3136 Apr 06 '16 at 01:09
  • 2
    C is definitely case sensitive when it comes to identifiers in the language itself. i.e. you can have two separate functions called Main() and main(). But file names are not C identifiers and in that case [sic] it is platform (and implementation) defined. – Deltics Apr 06 '16 at 01:14
  • @immibis Most "Unix" filesystems (HFS, for example) are case-insensitive, that's correct, but they're also case-preserving. While it's not allowed to have a file called "Foo.h" and "foo.h" in the same directory, you can't refer to "Foo.h" by the name "foo.h". – Leandros Apr 06 '16 at 09:35