gcc编译成功,arm-linux-gcc编译报错,请高手指教!!
环境 RH9.0,gcc 3.2 arm-linux-gcc 2.95.3
编译以下程序gcc编译很顺利完成,但arm-linux-gcc 报错:
com1.c: In function `set_speed ':
com1.c:147: parse error before `int '
com1.c:149: `speed_arr ' undeclared (first use in this function)
com1.c:149: (Each undeclared identifier is reported only once
com1.c:149: for each function it appears in.)
com1.c:151: `name_arr ' undeclared (first use in this function)
程序源代码如下:
//copy by bobya2003
#include <stdio.h>
#include <string.h>
#include <malloc.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <termios.h>
#define FALSE 0
#define TRUE 1
int set_Parity(int fd,int databits,int stopbits,int parity);
void set_speed(int fd,int speed);
int main(int argc,char **argv)
{
//int fd
int nread,nwrite;
char buff[255];
char *dev = "/dev/ttyS0 ";//com1
int fd = open( dev, O_RDWR | O_NOCTTY );//| O_NOCTTY );//O_NDELAY );//| O_NOCTTY | O_NDELAY O_NONBLOCK
if (-1 == fd)
{
perror( "Can 't Open Serial Port ");
//exit(1);
}
else
{
set_speed(fd,115200 );
if (set_Parity(fd,8,1, 'N ') == FALSE)
{
printf( "Set Parity Error\n ");
close(fd);
// exit(1);
}
else
{
printf( "com1 is OK!\n ");
}
}
while(1)
{
nread = read(fd,buff,255);
if (nread> 0)
{
buff[nread]= '\0 ';
printf( "The Read Data:%d,%s\n ",nread,buff);
printf( "Ready send!\n ");
nwrite=write(fd, "12345 ",5);
if (nwrite> 0) printf( "send OK\n ");
}
}
close(fd);
//exit(0);
}
int set_Parity(int fd,int databits,int stopbits,int parity)
{
struct termios options;
if ( tcgetattr( fd,&options) != 0) {
perror( "SetupSerial 1 ");
return(FALSE);
}
options.c_cflag &= ~CSIZE;
&nbs