Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > A #define that Iīm not used to

Reply
Thread Tools

A #define that Iīm not used to

 
 
Morris Dovey
Guest
Posts: n/a
 
      02-12-2008
"(E-Mail Removed)" wrote:
>
> 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.

--
Morris Dovey
DeSoto Solar
DeSoto, Iowa USA
http://www.iedu.com/DeSoto
 
Reply With Quote
 
 
 
 
alsmeirelles@gmail.com
Guest
Posts: n/a
 
      02-12-2008
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
 
Reply With Quote
 
 
 
 
alsmeirelles@gmail.com
Guest
Posts: n/a
 
      02-12-2008
On 12 fev, 17:47, Morris Dovey <(E-Mail Removed)> wrote:
> "(E-Mail Removed)" wrote:
>
> > Hello all,

>
> Bom dia!




You got it right and clear portuguese!

>
> > 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.


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

>
> --
> Morris Dovey
> DeSoto Solar
> DeSoto, Iowa USAhttp://www.iedu.com/DeSoto


 
Reply With Quote
 
Eric Sosman
Guest
Posts: n/a
 
      02-12-2008
Morris Dovey wrote:
> "(E-Mail Removed)" wrote:
>> 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 ();


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

>> #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


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.

--
http://www.velocityreviews.com/forums/(E-Mail Removed)

 
Reply With Quote
 
alsmeirelles@gmail.com
Guest
Posts: n/a
 
      02-12-2008
On 12 fev, 18:58, Eric Sosman <(E-Mail Removed)> wrote:
> Morris Dovey wrote:
> > "(E-Mail Removed)" wrote:
> >> 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 ();

>
> Yes, but this is not "a prototype statement." It is a
> function declaration with no prototype.
>
> >> #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

>
> 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.
>


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 `extern' is unusual, but harmless.
>
> --
> (E-Mail Removed)


 
Reply With Quote
 
Eric Sosman
Guest
Posts: n/a
 
      02-12-2008
(E-Mail Removed) wrote:
> [...]
> 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 ...
^

--
(E-Mail Removed)
 
Reply With Quote
 
Kaz Kylheku
Guest
Posts: n/a
 
      02-13-2008
On Feb 12, 11:47*am, Morris Dovey <(E-Mail Removed)> wrote:
> 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.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
problem in running a basic code in python 3.3.0 that includes HTML file Satabdi Mukherjee Python 1 04-04-2013 07:48 PM
I am buying all of the below Cisco equipment USED OR NEW. NOTE someline items say new or used, but I will buy them in both conditions. network buyer VOIP 0 12-23-2010 01:26 AM
Can Groovy be used in an applet and/or can it generate the Java bytecodes that then can be used in an applet? Casey Hawthorne Java 1 03-18-2009 12:56 AM
Is there a perl package, or data in a form easily used by a perlscript, that can be used to determine when to change to or from daylightsavings time? Ted Byers Perl Misc 23 11-15-2008 05:53 PM
Unreadable file on Canon S 400.I used a I used a Joseph Miller Digital Photography 3 01-13-2004 09:40 PM



Advertisments