|
|
|
|
||||||
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
#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? |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
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. |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
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(())? |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
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;}}} |
|
|
|
#5 |
|
Messages: n/a
Hébergeur: |
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. |
|
![]() |
| Outils de la discussion | |
|
|