我正在尝试编译一个处理mMIPS指令集内硬件剪辑的.c文件,但是我似乎在''results = sfu1'的行中得到错误''在宏数参数数量上存在分歧'' '当我尝试使用lcc -o mips_mem.bin image.c编译我的文件时。我不明白为什么它会给我这个错误。
这是image.c:
#!/bin/bash
if [ "$(id -u)" != "0" ]; then
echo "Must be root to run this script!"
exit 1
fi
##### CONSTANTS -
report=/home/chron/Desktop/report.log
#router=/home/chron/Desktop/router.log
red=`tput bold;tput setaf 1`
yellow=`tput bold;tput setaf 3`
green=`tput bold;tput setaf 2`
blue=`tput bold;tput setaf 4`
magenta=`tput bold;tput setaf 5`
cyan=`tput bold;tput setaf 6`
white=`tput sgr0`
##### FUNCTIONS -
pingtest() {
ping=`ping -c 3 localhost | tail -2`
loss=`echo $ping | cut -d"," -f3 | cut -d" " -f2`
delay=`echo $ping | cut -d"=" -f2 | cut -d"." -f1`
if [ "$loss" = "100%" ]; then
echo -n $red$1$white is not responding at all | mail -s'REPORT' localhost
echo 'You have mail in /var/mail!'
echo `date` $1 is not responding at all >> $report
elif [ "$loss" != "0%" ]; then
echo $yellow$1$white is responding with some packet loss
else
if [ "$delay" -lt 100 ]; then
echo $green$1$white is responding normally
else
echo $yellow$1$white is responding slow
fi
fi
}
check() {
if [ "$2" != "" -a "$2" $3 ] ; then
echo -n $green$1$white' '
else
echo -n $red$1$white' '
echo `date` $1 was not $3 >> $report
fi
}
##### __MAIN__ -
pingtest localhost # hostname or ip
echo "Server Configuration:"
check hostname `hostname -s` '= localhost'
check domain `hostname -d` '= domain.com'
check ipaddress `hostname -I | cut -d" " -f1` '= 10.10.0.6'
check gateway `netstat -nr | grep ^0.0.0.0 | cut -c17-27` '= 10.10.0.1'
echo
echo "Integrity of Files:"
check hostsfile `md5sum /etc/hosts | grep 7c5c6678160fc706533dc46b95f06675 | wc -l` '= 1'
check passwd `md5sum /etc/passwd | grep adf5a9f5a9a70759aef4332cf2382944 | wc -l` '= 1'
#/etc/inetd.conf is missing...
echo
#echo "Integrity of Website:"
#check www/index.html `lynx -reload -dump http://<LOCALIP> 2>&1 | md5sum | cut -d" " -f1 '=<MD5SUM>'
#echo
echo "Incoming attempts:"
#lynx -auth user:password -dump http://10.10.0.1 >> $router 2>&1
check telnet `grep \ 23$ $PWD/router.log | wc -l` '= 0'
check ftp `grep \ 21$ $PWD/router.log | wc -l` '= 0'
check ssh `grep \ 22$ $PWD/router.log | wc -l` '=0'
check smtp `grep \ 25$ $PWD/router.log | wc -l` '=0'
check dns `grep \ 53$ $PWD/router.log | wc -l` '=0'
echo
}
有人可以解释这个错误的含义以及修复方法吗?
答案 0 :(得分:1)
sfu1
宏需要2个参数,但您只提供一个参数。
这段代码会导致同样的错误:
result = sfu1(1);
校正:
result = sfu1(
-7 * (int)buf_i[(a - 1) * WIDTH + b - 1] +
5 * (int)buf_i[(a - 1) * WIDTH + b] +
2 * (int)buf_i[(a - 1) * WIDTH + b + 1] +
-1 * (int)buf_i[a * WIDTH + b - 1] +
15 * (int)buf_i[a * WIDTH + b] +
-1 * (int)buf_i[a * WIDTH + b + 1] +
2 * (int)buf_i[(a + 1) * WIDTH + b - 1] +
5 * (int)buf_i[(a + 1) * WIDTH + b] +
-7 * (int)buf_i[(a + 1) * WIDTH + b + 1] +
128
, 2 // <<<<<<<<< missing argument in your snippet
);
我刚刚添加2
作为第二个参数作为示例,因此您的程序编译时没有错误,但它可能不起作用。我不知道那些宏的第二个参数应该是什么。
您的代码可能不正确或调用未定义的行为,但这是另一个问题。