【发布时间】:2016-04-06 00:57:05
【问题描述】:
所以每当我尝试在我的服务器上运行我的 Makefile 时,它总是在 '*' 令牌之前给我错误是“Memory.c: 9 error: expected ')'。但是当我尝试自己运行它时电脑,它工作得很好。我一直试图找出问题所在,但似乎找不到。
我附上了我的程序这一部分中使用的 3 个文件。 Memory.c、Memory.h 和 ProcessInput.h。
这是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;
}
}
这是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);
ProcessInput.h 中唯一使用的是 ProcessInput.h 中定义的流程结构
这是 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);
我不太清楚为什么它给了我这个错误。我不知道我应该把丢失的右支架放在哪里。非常感谢任何建议!
编辑:据了解,这些是我查看但无济于事的以下问题。
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/
感谢大家的帮助!
【问题讨论】:
-
补充一下,我已经尝试查看遇到相同问题的人在 Stack Overflow 上提出的其他问题,但为每个问题提供的解决方案已经由我完成。
-
您应该编辑您的问题以包含您发现的问题的列表,以帮助防止它作为重复而被关闭。
-
服务器是否运行 Linux 而您的计算机是否运行 Windows?
-
是的,它正在运行 Linux。 John3136 的解决方案对我有用。当我去重命名我的文件时,我的一个小事后见之明。谢谢大家的帮助!