我正在编写的C程序中遇到此错误:
library(USAboundaries)
library(sf)
county <- us_counties() %>%
filter(str_detect(statefp,"02|72|78|15|66")==FALSE) %>%
mutate(geoid = as.integer(geoid))
for(i in 1:nrow(county)){
county$neighbor[i] <- county$geoid[unlist(st_is_within_distance(county[i,],county,70000,sparse = TRUE ))]
}
和
progra10.c:48:25: error: expected ‘;’,‘,’ or ‘)’ before numeric constant
#define LAST_INDEX ARRAY_SIZE - 1
我通过以下命令使用GCC编译器:
gcc -Wall -ansi -oprogram10.exe program10.c -lm
这是错误似乎所指的代码:
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,
我不知道为什么会导致该错误。我已经检查了打开的注释,选项卡,打开的字符串,等等,但是我无法修复此错误。在编译时,此错误是唯一的错误,只有在main的函数调用参数中每次使用LAST_INDEX时,才会重复此错误。我知道我程序的其余部分都有错误,但是编译甚至没有显示它们,使我相信它无法克服这些错误。
函数如下:
功能原型:
#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 */
函数调用:
int sequential_search(int seq_data,int target_location);
功能定义:
sequential_search(seq_data,LAST_INDEX,search_target,target_location);
感谢您的帮助!