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: -
void manage_data( TEntity * inEntity, TState inFromState, TEvent inEvent, TEventArgs * inArgs )
-
{
-
// arguments *auxArgs;
-
// int rc = AUTOMAT_OK;
-
// char aux[4];
-
-
// auxArgs=inArgs;
-
// auxArgs->trama.flag_s = 62;
-
/* auxArgs->trama.address = 0x69;
-
// auxArgs->trama.control = 4;
-
-
// memset(auxArgs->trama.data,'\0',MAX);
-
// strcpy(auxArgs->trama.data,auxArgs->paquete.data);
-
***** //si cabe n, se incluye en la trama
-
-
if (strlen(auxArgs->trama.data)<256)//261-(num(4)+ ~(1) + '/0'(1))
-
{
-
strcat(auxArgs->trama.data,"~");//se escribe una virgulilla
-
snprintf(aux,4,"%d",auxArgs->paquete.n);//se almacena el número de caracteres leídos
-
strcat(auxArgs->trama.data,aux);
-
}
-
strcat(auxArgs->trama.data,"\0");
-
-
auxArgs->trama.FCS1 = 0;
-
auxArgs->trama.FCS2 = 0;
-
auxArgs->flag_e = 62;
-
*/
-
// return rc;
-
}
----------------------------------------------------------------------
"$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...
7 1776
By the way.
Other functions have the same header
type name( TEntity * inEntity, TState inFromState, TEvent inEvent, TEventArgs * inArgs )
and work properly
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
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:
___________________________________ -
#include <stdio.h>
-
#include <stdlib.h>
-
#include <string.h>
-
#include <unistd.h>
-
-
#include <IFTI_P2_automat.h>
-
-
#define REACHED_EOF 3
-
#define MAX 261
-
-
-
typedef struct{
-
char data[MAX];
-
int n;
-
}packet;
-
-
typedef struct
-
{
-
char flag_s;
-
char address;
-
unsigned char control;
-
char data[MAX];
-
unsigned char FCS1;
-
unsigned char FCS2;
-
char flag_e;
-
}frame;
-
-
typedef struct{
-
frame trama;
-
packet paquete;
-
FILE* file;
-
int tty;
-
}arguments;
-
-
-
/* ------------------------------------------------------------
-
* State definitions
-
* ------------------------------------------------------------ */
-
enum {
-
TX_STATE_INITIAL = AUTOMAT_INITIAL_STATE,
-
TX_STATE_ERROR,
-
TX_STATE_READING,
-
TX_STATE_FRAMING,
-
TX_STATE_WAITING
-
};
-
-
#define TX_STATE_TEXT(X) \
-
(X==TX_STATE_INITIAL)? "TX_STATE_INITIAL" : \
-
(X==TX_STATE_ERROR)? "TX_STATE_ERROR" : \
-
(X==TX_STATE_READING)? "TX_STATE_READING" : \
-
(X==TX_STATE_FRAMING)? "TX_STATE_FRAMING" : \
-
(X==TX_STATE_WAITING)? "TX_STATE_WAITING" : \
-
"UNDEF"
-
-
-
/* ------------------------------------------------------------
-
* Event definitions
-
* ------------------------------------------------------------ */
-
enum {
-
TX_EV_OPERATIVE = 1,
-
TX_EV_READOK,
-
TX_EV_FRAMED,
-
TX_EV_ACK_RECEIVED,
-
};
-
-
/* ------------------------------------------------------------
-
* Action definitions
-
* ------------------------------------------------------------ */
-
TAutomat * TX_automat_SW_define( );
-
-
int internal_error( TEntity * inEntity,
-
TState inFromState,
-
TEvent inEvent,
-
TEventArgs * inArgs );
-
-
int read_data( TEntity * inEntity,
-
TState inFromState,
-
TEvent inEvent,
-
TEventArgs * inArgs );
-
-
int manage_data( TEntity * inEntity,
-
TState inFromState,
-
TEvent inEvent,
-
TEventArgs * inArgs );
-
-
int send_data_wait_response( TEntity * inEntity,
-
TState inFromState,
-
TEvent inEvent,
-
TEventArgs * inArgs );
-
-
-
________________________
Thanks for your attention
I think that's becasue ur comment styles.
U are mixing c and c++ commenting styles
Savage
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. -
/* Look I have started a multi-line comment
-
-
-
// and now I have put in a single line comment
-
-
and now I am ending the multi-line comment */
-
It is never a good idea to nest comments, confusion results.
Mixing them is OK, although possibly bad practice, I suspect it is because they are nested.
i.e. -
/* Look I have started a multi-line comment
-
-
-
// and now I have put in a single line comment
-
-
and now I am ending the multi-line comment */
-
It is never a good idea to nest comments, confusion results.
So, as we can see it's not OK.
Savage
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
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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...
|
by: John Temples |
last post by:
Given this code:
extern volatile unsigned char v;
int main(void)
{
v;
return 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...
|
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...
|
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...
|
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...
|
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...
|
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 =...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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...
|
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...
|
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,...
|
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...
| |