A #define that I´m not used to

M

Morris Dovey

Hello all,

Bom dia!
Could someone have the generosity of explaining me what this #defines
define?

#define YPAD_PROTOTYPE(PAD) extern void PAD ();

Expands to produce a prototype statement. For example:

YPAD_PROTOTYPE(my_function)

produces

extern void my_function ();
#define YPAD_FUNCTION(PAD) extern void PAD (VarP) xPrsNode VarP;

Here

YPAD_FUNCTION(my_function)

Expands to produce

extern void my_function (VarP) xPrsNode VarP

which is almost certainly expanded further by other macro
definitions.
 
A

alsmeirelles

Hello all,

Could someone have the generosity of explaining me what this #defines
define?

#define YPAD_PROTOTYPE(PAD) extern void PAD ();
#define YPAD_FUNCTION(PAD) extern void PAD (VarP) xPrsNode VarP;
#define YPRD_PROTOTYPE(PAD) extern int PAD ();
#define YPRD_FUNCTION(PAD) extern int PAD (VarP) xPrsNode VarP;


Thanks a lot,

André LS Meirelles
 
A

alsmeirelles


:)

You got it right and clear portuguese!
Expands to produce a prototype statement. For example:

YPAD_PROTOTYPE(my_function)

produces

extern void my_function ();


Here

YPAD_FUNCTION(my_function)

Expands to produce

extern void my_function (VarP) xPrsNode VarP

which is almost certainly expanded further by other macro
definitions.

Yeah, that makes a lot of sense, thanks!!
 
E

Eric Sosman

Morris said:
Bom dia!


Expands to produce a prototype statement. For example:

YPAD_PROTOTYPE(my_function)

produces

extern void my_function ();

Yes, but this is not "a prototype statement." It is a
function declaration with no prototype.
Here

YPAD_FUNCTION(my_function)

Expands to produce

extern void my_function (VarP) xPrsNode VarP

No, there is also a semicolon `;' in the macro expansion.
which is almost certainly expanded further by other macro
definitions.

It may be further expanded, but I wouldn't say "almost
certainly." It looks very much like the start of an old-
style (pre-prototype) function definition, and is probably
followed by a `{}'-enclosed block that is the function body.

The `extern' is unusual, but harmless.
 
A

alsmeirelles

Yes, but this is not "a prototype statement." It is a
function declaration with no prototype.



No, there is also a semicolon `;' in the macro expansion.


It may be further expanded, but I wouldn't say "almost
certainly." It looks very much like the start of an old-
style (pre-prototype) function definition, and is probably
followed by a `{}'-enclosed block that is the function body.

That´s the problem, I don´t know wich #define is beeing expanded. The
function has a body (a big one in fact). The definition starts like
this:

YPAD_FUNCTION(yPAD_mmc)
 
E

Eric Sosman

[...]
That´s the problem, I don´t know wich #define is beeing expanded. The
function has a body (a big one in fact). The definition starts like
this:

YPAD_FUNCTION(yPAD_mmc)

The expansion is

extern void yPAD_mmc (VarP) xPrsNode VarP;

Have you, perhaps, been confused by the similarity of
the macro names? They differ by just one character, buried
in the middle and topologically similar:

#define YPAD_PROTOTYPE ...
#define YPRD_PROTOTYPE ...
^

#define YPAD_FUNCTION ...
#define YPRD_FUNCTION ...
^
 
K

Kaz Kylheku

Here

   YPAD_FUNCTION(my_function)

Expands to produce

   extern void my_function (VarP) xPrsNode VarP

Also, there is a semicolon.
which is almost certainly expanded further by other macro
definitions.

I would guess that likely works like this:

YPAD_FUNCTION(my_function)
{
/* body that references VarP of type xPrsNode
}

My guess is that the YPAD macros are conditionally defined to switch
between ANSI declarations and old-style.
 

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
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top