What's the meaning of the macro 'OF'

S

StdNewer

#ifndef OF /* function prototypes */
# ifdef STDC
# define OF(args) args
# else
# define OF(args) ()
# endif
#endif

void func OF( args );

I saw some C programs written like this. Why?
 
I

Ian Collins

StdNewer said:
#ifndef OF /* function prototypes */
# ifdef STDC
# define OF(args) args

Are you sure that wasn't define OF(args) (args)?
# else
# define OF(args) ()
# endif
#endif

void func OF( args );

I saw some C programs written like this. Why?

Very old (before 1989) compilers didn't have function prototypes.
Expand the macros and see what you get with and without STDC defined.
 
S

StdNewer

Are you sure that wasn't define OF(args) (args)?

I see,thanks very much.
I wrote wrong in "void func OF(args)"; it should be: void func
OF((args));
But if "#define OF(args) ()",this function is vod fun(()).
two parentheses,right?
why didn't he define "OF" as you do,and declare function as
func OF(),not func OF(())?
 
B

Ben Pfaff

Ian Collins said:
Are you sure that wasn't define OF(args) (args)?

Probably not: then it would only work with 0- or 1-parameter
functions, because a 1-argument macro cannot be invoked with
multiple comma-separated arguments.
 
I

Ian Collins

StdNewer said:
I see,thanks very much.
I wrote wrong in "void func OF(args)"; it should be: void func
OF((args));
But if "#define OF(args) ()",this function is vod fun(()).
two parentheses,right?
why didn't he define "OF" as you do,and declare function as
func OF(),not func OF(())?
See Ben's reply.
 

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,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top