PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.lang.c > What's the meaning of the macro 'OF'
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
What's the meaning of the macro 'OF'

Réponse
 
LinkBack Outils de la discussion
Vieux 02/02/2008, 06h02   #1
StdNewer
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut What's the meaning of the macro 'OF'

#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?
  Réponse avec citation
Vieux 02/02/2008, 06h42   #2
Ian Collins
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: What's the meaning of the macro 'OF'

StdNewer wrote:
> #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.

--
Ian Collins.
  Réponse avec citation
Vieux 02/02/2008, 07h11   #3
StdNewer
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: What's the meaning of the macro 'OF'

On 2ÔÂ2ÈÕ, ÏÂÎç2ʱ42·Ö, Ian Collins <ian-n...@hotmail.com> wrote:
> StdNewer wrote:
> > #ifndef OF /* function prototypes */
> > # ifdef STDC
> > # define OF(args) args

>
> 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(())?

  Réponse avec citation
Vieux 02/02/2008, 07h11   #4
Ben Pfaff
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: What's the meaning of the macro 'OF'

Ian Collins <ian-news@hotmail.com> writes:

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

>
> 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.
--
char a[]="\n .CJacehknorstu";int putchar(int);int main(void){unsigned long b[]
={0x67dffdff,0x9aa9aa6a,0xa77ffda9,0x7da6aa6a,0xa6 7f6aaa,0xaa9aa9f6,0x11f6},*p
=b,i=24;for(+=!*p;*p/=4)switch(0[p]&3)case 0:{return 0;for(p--;i--;i--)case+
2:{i++;if(i)break;else default:continue;if(0)case 1:putchar(a[i&15]);break;}}}
  Réponse avec citation
Vieux 02/02/2008, 07h35   #5
Ian Collins
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: What's the meaning of the macro 'OF'

StdNewer wrote:
> On 2ÔÂ2ÈÕ, ÏÂÎç2ʱ42·Ö, Ian Collins <ian-n...@hotmail.com> wrote:
>> StdNewer wrote:
>>> #ifndef OF /* function prototypes */
>>> # ifdef STDC
>>> # define OF(args) args

>> 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(())?
>

See Ben's reply.

--
Ian Collins.
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 14h31.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,09452 seconds with 13 queries