473,405 Members | 2,310 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

C expects one expression ?

31
I hope you understand my poor english

This is my function (it used to return int), I got the same error when I compiled it for first time (then it was in the ***** marked line), so I started to comment one by one trying to allocate my fault... i couldn't:
Expand|Select|Wrap|Line Numbers
  1. void manage_data( TEntity * inEntity, TState inFromState, TEvent inEvent, TEventArgs * inArgs )
  2. {
  3. //    arguments *auxArgs;
  4. //    int rc = AUTOMAT_OK;
  5. //    char aux[4];
  6.  
  7. //    auxArgs=inArgs;
  8. //    auxArgs->trama.flag_s = 62;
  9. /*    auxArgs->trama.address = 0x69;
  10. //    auxArgs->trama.control = 4;
  11.  
  12. //    memset(auxArgs->trama.data,'\0',MAX);
  13. //    strcpy(auxArgs->trama.data,auxArgs->paquete.data);
  14. *****    //si cabe n, se incluye en la trama
  15.  
  16.     if (strlen(auxArgs->trama.data)<256)//261-(num(4)+ ~(1) + '/0'(1))
  17.     {
  18.         strcat(auxArgs->trama.data,"~");//se escribe una virgulilla
  19.         snprintf(aux,4,"%d",auxArgs->paquete.n);//se almacena el número de caracteres leídos
  20.         strcat(auxArgs->trama.data,aux);
  21.     }
  22.     strcat(auxArgs->trama.data,"\0");
  23.  
  24.     auxArgs->trama.FCS1 = 0;
  25.     auxArgs->trama.FCS2 = 0;
  26.     auxArgs->flag_e = 62;    
  27. */
  28.  // return rc;
  29. }
----------------------------------------------------------------------
"$gcc -g -Wall -ansi -I . TX_automat_SW.c" returns:


TX_automat_SW.c: In function ‘manage_data’:
TX_automat_SW.c:83: error: expected expression before ‘/’ token
TX_automat_SW.c:84: error: expected expression before ‘/’ token
TX_automat_SW.c:85: error: expected expression before ‘/’ token
TX_automat_SW.c:87: error: expected expression before ‘/’ token
TX_automat_SW.c:88: error: expected expression before ‘/’ token
TX_automat_SW.c:108: error: expected expression before ‘/’ token


I just can't figure what is it expecting...
May 30 '07 #1
7 1776
Sieira
31
By the way.

Other functions have the same header

type name( TEntity * inEntity, TState inFromState, TEvent inEvent, TEventArgs * inArgs )

and work properly
May 30 '07 #2
Savage
1,764 Expert 1GB
By the way.

Other functions have the same header

type name( TEntity * inEntity, TState inFromState, TEvent inEvent, TEventArgs * inArgs )

and work properly
Void functions cannot return a value.

If u wish to return a int make a function type to be a int.

Savage
May 30 '07 #3
Sieira
31
Void functions cannot return a value.

If u wish to return a int make a function type to be a int.

Savage

Function returns int, I wrote void because I commented the return instruction too.

OK, by deleting every single-line comment, i got it working.

Can anyone explain me it?



That .c file implements his homonym .h, which is as follows:
___________________________________
Expand|Select|Wrap|Line Numbers
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <unistd.h>
  5.  
  6. #include <IFTI_P2_automat.h>
  7.  
  8. #define    REACHED_EOF        3
  9. #define MAX 261
  10.  
  11.  
  12. typedef struct{
  13.      char data[MAX];
  14.      int n;
  15. }packet;
  16.  
  17. typedef struct
  18. {
  19.      char flag_s;
  20.      char address;
  21.      unsigned char control;
  22.      char data[MAX];
  23.      unsigned char FCS1;
  24.      unsigned char FCS2;
  25.      char flag_e;
  26. }frame;
  27.  
  28. typedef struct{
  29.     frame trama;
  30.     packet paquete;
  31.     FILE* file;
  32.     int tty;
  33. }arguments;
  34.  
  35.  
  36. /* ------------------------------------------------------------ 
  37.  * State definitions
  38.  * ------------------------------------------------------------ */
  39. enum {
  40.     TX_STATE_INITIAL = AUTOMAT_INITIAL_STATE,
  41.     TX_STATE_ERROR,
  42.     TX_STATE_READING,
  43.     TX_STATE_FRAMING,
  44.     TX_STATE_WAITING
  45. };
  46.  
  47. #define TX_STATE_TEXT(X) \
  48. (X==TX_STATE_INITIAL)? "TX_STATE_INITIAL" : \
  49. (X==TX_STATE_ERROR)? "TX_STATE_ERROR" : \
  50. (X==TX_STATE_READING)? "TX_STATE_READING" : \
  51. (X==TX_STATE_FRAMING)? "TX_STATE_FRAMING" : \
  52. (X==TX_STATE_WAITING)? "TX_STATE_WAITING" : \
  53. "UNDEF"
  54.  
  55.  
  56. /* ------------------------------------------------------------ 
  57.  * Event definitions
  58.  * ------------------------------------------------------------ */
  59. enum {
  60.   TX_EV_OPERATIVE = 1,
  61.   TX_EV_READOK,
  62.   TX_EV_FRAMED,
  63.   TX_EV_ACK_RECEIVED,
  64. };
  65.  
  66. /* ------------------------------------------------------------ 
  67.  * Action definitions
  68.  * ------------------------------------------------------------ */
  69. TAutomat * TX_automat_SW_define( );
  70.  
  71. int internal_error(    TEntity * inEntity,
  72.             TState inFromState,
  73.             TEvent inEvent,
  74.             TEventArgs * inArgs );
  75.  
  76. int read_data(    TEntity * inEntity,
  77.             TState inFromState,
  78.             TEvent inEvent,
  79.             TEventArgs * inArgs );
  80.  
  81. int manage_data(    TEntity * inEntity,
  82.             TState inFromState,
  83.             TEvent inEvent,
  84.             TEventArgs * inArgs );
  85.  
  86. int send_data_wait_response(    TEntity * inEntity,
  87.             TState inFromState,
  88.             TEvent inEvent,
  89.             TEventArgs * inArgs );
  90.  
  91.  
  92.  
________________________
Thanks for your attention
May 30 '07 #4
Savage
1,764 Expert 1GB
I think that's becasue ur comment styles.

U are mixing c and c++ commenting styles

Savage
May 30 '07 #5
Banfa
9,065 Expert Mod 8TB
I think that's becasue ur comment styles.

U are mixing c and c++ commenting styles
Mixing them is OK, although possibly bad practice, I suspect it is because they are nested.

i.e.

Expand|Select|Wrap|Line Numbers
  1. /* Look I have started a multi-line comment
  2.  
  3.  
  4. // and now I have put in a single line comment
  5.  
  6. and now I am ending the multi-line comment */
  7.  
It is never a good idea to nest comments, confusion results.
May 30 '07 #6
Savage
1,764 Expert 1GB
Mixing them is OK, although possibly bad practice, I suspect it is because they are nested.

i.e.

Expand|Select|Wrap|Line Numbers
  1. /* Look I have started a multi-line comment
  2.  
  3.  
  4. // and now I have put in a single line comment
  5.  
  6. and now I am ending the multi-line comment */
  7.  
It is never a good idea to nest comments, confusion results.
So, as we can see it's not OK.

Savage
May 30 '07 #7
Sieira
31
I found my mistake.

It's possible to mix this type of comments (i've done it so many times),
you can do it, but if you do, you can't try to compile using the -ansi flag in gcc...

Anyway, i'll try not to do it again. Thank you for your replies
May 31 '07 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Mini Mouse | last post by:
Hiya folks, I'm getting the following error(s) below and I'm at a bit of a loss as to how to correct it. When I give it a parameter it then complains it needs two parameters and the second one...
1
by: Senthil | last post by:
Hi, I created a stored procedure in the sql server. I try to insert a record from the aspx page. But I keep getting this error, "procedure expects parameter <@firstname>, which was not...
14
by: John Temples | last post by:
Given this code: extern volatile unsigned char v; int main(void) { v; return 0; }
0
by: vibhesh | last post by:
Hello, I have C++ code that I used to compile on VC++ 6.0 compiler. Now after some modifications I have successfully compiled the code in VC++ 7.0 (.NET). The code is fully unmanaged. The...
8
by: TJ | last post by:
I need to be able to pass a pointer to a (managed code) Stream object to a COM method so it can serialize its data into the stream. I have a C# application that makes uses of Randolf Duke's...
28
by: Marc Gravell | last post by:
In Linq, you can apparently get a meaningful body from and expression's .ToString(); random question - does anybody know if linq also includes a parser? It just seemed it might be a handy way to...
18
by: dspfun | last post by:
Hi! The words "expression" and "statement" are often used in C99 and C- textbooks, however, I am not sure of the clear defintion of these words with respect to C. Can somebody provide a sharp...
15
by: Andreas Eibach | last post by:
.... but I have an unsigned long value in the printf. This warning came when I used gcc 4.x to compile. .... unsigned long offset = 0; .... Well OK, an "easy" way would be instead of printf...
7
by: roseple | last post by:
Hi, can anyone please help me why I got this error every I uploaded files. Error: Here is the code on the said warning message: # Gather all required data $name =...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.