ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
/*
* 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"
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 );
Originally posted by ams 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;
}
this really does not make sense to me.
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 )
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.