LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-02-2005, 01:22 AM   #1
ams
LQ Newbie
 
Registered: Feb 2005
Posts: 12

Rep: Reputation: 0
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?
 
Old 03-02-2005, 02:04 AM   #2
nikm
LQ Newbie
 
Registered: Mar 2005
Posts: 24

Rep: Reputation: 15
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.
 
Old 03-02-2005, 03:03 AM   #3
fleluhern
LQ Newbie
 
Registered: Aug 2003
Location: Lyon (France)
Distribution: RH ES3, RH ES4, Fedora Core 3 - Solaris 8/10
Posts: 4

Rep: Reputation: 0
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
 
Old 03-02-2005, 04:30 AM   #4
ams
LQ Newbie
 
Registered: Feb 2005
Posts: 12

Original Poster
Rep: Reputation: 0
thank you buddy.....
i'll try them...
 
Old 03-02-2005, 04:48 AM   #5
addy86
Member
 
Registered: Nov 2004
Location: Germany
Distribution: Debian Testing
Posts: 332

Rep: Reputation: 31
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 );
 
Old 03-02-2005, 04:56 AM   #6
perfect_circle
Senior Member
 
Registered: Oct 2004
Location: Athens, Greece
Distribution: Slackware, arch
Posts: 1,783

Rep: Reputation: 53
Re: parse error?

Quote:
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 )
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Parse Error, but why? Mistro116@yahoo.com Programming 2 11-13-2005 02:38 PM
in gcc compiler error: parse error before string constsnt cynthia_thomas Linux - Networking 1 10-20-2005 01:29 AM
parse error with bc fisayo Programming 7 08-04-2005 09:23 AM
Parse Error verbatim Programming 3 04-22-2005 09:16 AM
What is parse error ? edhan Linux - Newbie 64 09-17-2003 06:49 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:45 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration