I have been getting this error in a C program that I'm writing:
progra10.c:48:25: error: expected ‘;’, ‘,’ or ‘)’ before numeric constant
#define LAST_INDEX ARRAY_SIZE - 1
and
program10.c:47:25: error: expected ‘;’, ‘,’ or ‘)’ before numeric constant
#define ARRAY_SIZE 20
^
program10.c:48:25: note: in expansion of macro ‘DATA_SIZE’
#define LAST_INDEX ARRAY_SIZE - 1
^~~~~~~~~~
program10.c:64:42: note: in expansion of macro ‘LAST_INDEX’
int sequential_search(int seq_data, int LAST_INDEX, int search_target,
I use the GCC compiler with this command:
gcc -Wall -ansi -oprogram10.exe program10.c -lm
This is the code that the error seems to be referring to:
#define COURSE_NUMBER "C Programming" /* Class */
#define PROGRAM_NUMBER 10 /* Program Number */
#define PROGRAMMER_NAME "Name" /* Programmer's Name */
#define ARRAY_SIZE 20 /* Size of the array */
#define LAST_INDEX ARRAY_SIZE - 1 /* The last index in the array */
I have no clue why it would be causing that error. I've checked for open comments, tabs, open strings, among other things, and I have not been able to fix this error. While compiling, this error is the only error, only it repeats for every time that LAST_INDEX is used in a function call parameter in main. I know the rest of my program has errors, but the compilation doesn't even show them, leading me to believe that it can't get past this.
The functions look like this:
Function Prototype:
int sequential_search(int seq_data, int LAST_INDEX, int search_target,
int target_location);
Function Call:
sequential_search(seq_data, LAST_INDEX, search_target, target_location);
Function Definition:
int sequential_search(int seq_data, int LAST_INDEX, int search_target,
int target_location)
Thanks for your help!