Discussion Forum

problem with FUNC

Next Thread | Thread List | Previous Thread Start a Thread | Settings

DetailsMessage
Read-Only
Author
Jan Goormans
Posted
26-Apr-2004 22:24 GMT
Toolset
C51
New! problem with FUNC
I always get an error 129 (missing ';' before 'void') when I compile in this part:
func void iicstart (void)
{
sda = 1;
scl = 1;
del4us ()
sda = 0;
del4us ()
scl = 0;
del4us ()
}

what is wrong?
Read-Only
Author
Andrew Neil
Posted
26-Apr-2004 22:28 GMT
Toolset
C51
New! RE: problem with FUNC
Is this supposed to be 'C'?

If so, what is func?
Read-Only
Author
Drew Davis
Posted
26-Apr-2004 23:18 GMT
Toolset
C51
New! RE: problem with FUNC
"func" is the problem.

"Missing ; before <token>" is one of those compiler error messages that you wish actually says what it means. Normally, I see this error when there is an undefined type for a return value of a function.

ForgotToInclude f()

- Missing ; before f.
Read-Only
Author
Andy Neil
Posted
26-Apr-2004 23:40 GMT
Toolset
C51
New! RE: problem with FUNC
"'Missing ; before <token>' is one of those compiler error messages that you wish actually says what it means."

What it means is that the compiler expects nothing before <token>; therefore, if it finds something before <token>, it assumes that there should've been a ';' after the "something" !!
Read-Only
Author
Jon Ward
Posted
26-Apr-2004 23:16 GMT
Toolset
C51
New! RE: problem with FUNC
Should there be a ; after del4us ()???

Jon
Read-Only
Author
Andy Neil
Posted
26-Apr-2004 23:41 GMT
Toolset
C51
New! RE: problem with FUNC
"Should there be a ; after del4us ()???"

Surely, there should be a ';' after each del4us() ?!
Read-Only
Author
Drew Davis
Posted
27-Apr-2004 02:05 GMT
Toolset
C51
New! RE: problem with FUNC
Maybe del4us() is a macro that inserts its own semicolons?

#define del4us() _nop_;_nop_;_nop_;_nop_;

(Not a style I would recommend. I write macros that look like functions assuming I'll put a semicolon after them at the point of use.)
Read-Only
Author
Jon Ward
Posted
27-Apr-2004 14:02 GMT
Toolset
C51
New! RE: problem with FUNC
On second look, it appears you have debugger functions confused with C functions.

When writing your C program, you must use ANSI C rules. And, func is not a part of that rule set.

If your function is intended to be used in your program, you should modify it as follows:

void iicstart (void)
{
sda = 1;
scl = 1;
del4us ();
sda = 0;
del4us ();
scl = 0;
del4us ();
}

If, on the other hand, the function is intended to be used in the debugger (to simulate the input of an I2C input signal) you should modify it as follows:

func void iicstart (void) {
sda = 1;
scl = 1;
del4us ();
sda = 0;
del4us ();
scl = 0;
del4us ();
}

Jon

Next Thread | Thread List | Previous Thread Start a Thread | Settings