What is this - weird function definition

Y

Yamin

I found some code that seems a bit weird and is refusing to compile on
GCC...it apparently used to compile fine on other comilers.

typedef void ASY_TESTPROC_T __((OIDC_T lastmatch, int compc, OIDC_T *compl,
....));

There are several other ASY_XXXX defintion following, but AST_TESTPROC_T is
the first one.

There is macro: __(x) defined which basically does this
iifdef __STDC__
# define __(x) x
#else
#define __(x)

doing this, the output should be:

typedef void ASY_TESTPROC_T (OIDC_T lastmatch, int compc, OIDC_T *compl,
....);

But on the output of the preprocessor, I get
typedef void ASY_TESTPROC_T ((OIDC_T lastmatch, int compc, OIDC_T *compl,
....));

The other ASY_XXX appear to come out as expected.

First of all: am I understanding this code correctly. Is it a function
pointer declaration? From what I've read about the __() macro, it is
normally used for function prototypes. Secondly, anyone have any ideas why
it might not compile?

Yamin
 
J

Jonathan Mcdougall

I found some code that seems a bit weird and is refusing to compile on
GCC...it apparently used to compile fine on other comilers.

typedef void ASY_TESTPROC_T __((OIDC_T lastmatch, int compc, OIDC_T *compl,
...));

There are several other ASY_XXXX defintion following, but AST_TESTPROC_T is
the first one.

There is macro: __(x) defined which basically does this
iifdef __STDC__

What is __STDC__? That is not C++.
# define __(x) x
#else
#define __(x)

doing this, the output should be:

Dunno, you don`t tell us if __STDC__ is defined or not.
First of all: am I understanding this code correctly. Is it a function
pointer declaration?

Not if ASY_TESTPROC_T is a name (would be a syntax error). If it is a
macro, show us what it is.
Secondly, anyone have any ideas why
it might not compile?

No, ask that in a newsgroup supporting your compiler. This is not standard
C++, as long as you don't give us standard code. Try to expand the macros
and try again.


Jonathan
 
Y

Yamin

Yamin said:
I found some code that seems a bit weird and is refusing to compile on
GCC...it apparently used to compile fine on other comilers.

typedef void ASY_TESTPROC_T __((OIDC_T lastmatch, int compc, OIDC_T *compl,
...));
[snip]

ARGHH!!.
I think I got an answer....
compl is a c++ keyword. That's prolly it. I'll verify it at work tomorrow.

Yamin
 
J

Jonathan Mcdougall

I found some code that seems a bit weird and is refusing to compile on
GCC...it apparently used to compile fine on other comilers.

typedef void ASY_TESTPROC_T __((OIDC_T lastmatch, int compc, OIDC_T *compl,
...));
[snip]

ARGHH!!.
I think I got an answer....
compl is a c++ keyword. That's prolly it. I'll verify it at work
tomorrow.

A c++ keyword? Is the new standard out? Damn.. nobody told me.


Jonathan
 
D

Dietmar Kuehl

A c++ keyword? Is the new standard out? Damn.. nobody told me.

Indeed, 'compl' is a keyword: it is a synonym for '~', the bitwise
complement operator. ... and what do you mean my "new standard"?
There is so far only one C++ standard: ISO 14882 (1998). You might
want to check section 2.5. (lex.digraph), paragraph 2.
 
J

Jonathan Mcdougall

compl is a c++ keyword.
Indeed, 'compl' is a keyword: it is a synonym for '~', the bitwise
complement operator. ...

Wow, did not know that (sorry to the op).
and what do you mean my "new standard"?

A joke.


Jonathan
 
Y

Yamin

Jonathan Mcdougall said:
Wow, did not know that (sorry to the op).


A joke.


Jonathan

I got ur joke...aka...sarcasm :) Sometimes, only sometimes...maybe 0.1% of
the time slamming someone with the C++ standard is not the correct response
in this group.

Yeah, the compl is a reserved name (as keyword is apparently wrong
terminology).
It took me by surprise. I only managed to find it by browsing around
looking for that macro and luckily clicked on a link which gave a list of
all the reserved names. It took my interest, and boom...there it was.

It's just really weird how watcom and green hills both accepted it. Guess
they could figure it out that the code meant compl as an identifier and the
reserved word. Or maybe they don't even reserve compl. Now that would be
implementation specific :)


Yamin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,145
Messages
2,570,824
Members
47,369
Latest member
FTMZ

Latest Threads

Top