parse error?
i tried to compile these code...
/* * Send the line out over the serial port, abort on error */ if( int serialSend( int r_serial_fd, char in_buf ) < 0 ) { fprintf(stderr, "%s: error sending buffer, aborting, %s!\n", r_proc_name, sys_errlist[errno] ); Terminate(E_SERIAL_SEND); } return; } and the it create an error.... [ams@lan ex8]$ gcc deviceSim.c deviceSim.c: In function `sendData': deviceSim.c:327: parse error before "int" deviceSim.c: At top level: deviceSim.c:333: parse error before "return" what does it means? |
I think you are trying to use c++ syntax in a c program or you are using c compiler to compile a c++.
either change the syntax or use g++ compiler. |
Hi!
You just have a tiny error in your code!!! if( int serialSend( int r_serial_fd, char in_buf ) < 0 ) Two solutions can be found to your mistake. First remove int, which is a type declaration, and which is THE mistake here. if( serialSend( int r_serial_fd, char in_buf ) < 0 ) Second, if you want to cast serialSend, modify your code like that: if( ((int)serialSend( int r_serial_fd, char in_buf )) < 0 ) I expect it could help you. Good luck |
thank you buddy.....
i'll try them... |
It might be helpful if you sended the complete definition of the function 'sendData()', and the declaration (header) of serialSend(). Why? Because
serialSend( int r_serial_fd, char in_buf ) wouldn't make much sense in C, since these variables are input values, but immediately after declaration, they do not contain any meaningful value. And even in C++, this would make sense only if serialSend was declared as something like int serialSend( int &r_serial_fd, char &in_buf ); |
Re: parse error?
Quote:
int serialSend( int r_serial_fd, char in_buf ) is a function declaration, not an execution. if you write: if( (int) serialSend( int r_serial_fd, char in_buf ) < 0 ), this means cast the returning value of serialSend to int. If t's already returning int, no need to do that. If you just want to check the returning value of serialSend do if( serialSend( r_serial_fd, char in_buf ) < 0 ). If you need to cast the values, because they are not ints do if( (int) serialSend( (int) r_serial_fd, char in_buf ) < 0 ) |
All times are GMT -5. The time now is 08:47 PM. |