1752554 Members
4645 Online
108788 Solutions
New Discussion юеВ

#error 2020

 
SOLVED
Go to solution
Eder Urruela
Frequent Advisor

#error 2020

My gcc return me the following mistakes:

"saverest.c", line 69: error #2020: identifier "FunctionArgList" is undefined
int ZtSave(Object, FunctionArgList)
^

"saverest.c", line 69: error #2141-D: unnamed prototyped parameters not allowed when body is present
int ZtSave(Object, FunctionArgList)
^

"saverest.c", line 70: error #2130: expected a "{"
ZtId Object;
^

and I have the following code:

int ZtSave(Object,FunctionArgList)
ZtId Object;
ZtArgList FunctionArgList;
{
Zt_FcnAttributes fcnatts;
int iscls, oldErrLevel = ZtErrLevel;
.
.
.

The problem is the declaration of ZtId Object and ZtArgList FunctionArglist, which is made after the function declaration. If I write the header like this:
int ZtSave(ZtId Object,ZtArgList FunctionArgList)
It works, and I have compiled other functions like this with the declaration after the header and it haven't return any mistake, and I don't know why, it could be because I need one more define in the Makefile?

Thanks gurus.
12 REPLIES 12
Steven Schweda
Honored Contributor
Solution

Re: #error 2020

> My gcc [...]

Which gcc is that? "gcc -v"? On what?
"uname -a"?

> and I have the following code:

And much more, which you haven't shared. A
small, _complete_ test case would be easier
to debug.

I find it interesting that the _first_
complaint refers to the _second_ parameter
(as if gcc thought that "Object" was a type,
but "FunctionArgList" was not).

But I can't see enough of the code to do more
than make guesses.
Dennis Handly
Acclaimed Contributor

Re: #error 2020

>My gcc return me the following mistakes:

Error 2020 is an aC++ error message, not gcc.
Did you use cc or aCC to compile? What does your compile line look like?

>The problem is the declaration of ZtId Object and ZtArgList FunctionArglist, which is made after the function declaration.

This is a garbage K&R style definition, you should use C++ or ANSI C style prototypes.

>I have compiled other functions like this with the declaration after

It only complained about FunctionArgList and not Object. Has FunctionArgList appeared before?
Dennis Handly
Acclaimed Contributor

Re: #error 2020

>Steven: as if aC++ thought that "Object" was a type, but "FunctionArgList" was not.

That's probably exactly the problem.
Eder Urruela
Frequent Advisor

Re: #error 2020

Sorry, I said gcc but I'm using cc. my command line to call the compiler is the next.

cc -c -O -Wp,-H256000 -DRELEASE -Dhpux -D_CLASSIC_TYPES -DX11R6 -I/hpi
vi/tape/usr/include/X11R2 -I/usr/include/X11R6 -I. -I../../inc saverest.c

and the varible FunctionArgList is a ZtArgList variable, which is the typedef of one struct in one library, I have other variables as the same kind, and I know it isn't problem of the library because the compiler undestand them.

Thanks!
Dennis Handly
Acclaimed Contributor

Re: #error 2020

>the variable FunctionArgList is a ZtArgList variable... I have other variables as the same kind, and I know it isn't problem of the library because the compiler understand them.

As Steven said, the problem is with Object, it's probably a type.

As I said, you should get rid of the garbage K&R definitions.
Eder Urruela
Frequent Advisor

Re: #error 2020

What's the K&R definitions?
Sorry but I don't Know much about unix.

Thanks and escuses for my little knowledge.
Dennis Handly
Acclaimed Contributor

Re: #error 2020

>What's the K&R definitions? Sorry but I don't know much about unix.

This is a C term, nothing to do with Unix.

K&R is the initial version of C before it became an official standard.

foo(x,y) int x,y { return x + y; }
This is a garbage K&R definition.

int foo(int x, int y);
This is a C++ or ANSI C prototype.
James R. Ferguson
Acclaimed Contributor

Re: #error 2020

Hi:

> What's the K&R definitions?

This might help, too:

http://en.wikipedia.org/wiki/K%26R_C

http://en.wikipedia.org/wiki/C99

Regards!

...JRF...
Dennis Handly
Acclaimed Contributor

Re: #error 2020

>Steven: as if gcc thought that "Object" was a type, but "FunctionArgList" was not.

Steven is correct. This type of garbage K&R definition is only legal in K&R. Neither HP C, aCC6 in C mode, nor gcc like this. They see the initial type (Object) and assume it is a parameter-type-list.