ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
int main (int argc, char **argv);
void count (FILE *f);
void usage (void);
int main(argc, argv)
int argc;
char *argv[];
{
int k;
char *cp;
int tflag, files;
</code>
....
more codes
and this compiled OK
I have two questions. the function prototype is ansi style and function definition is K&R style how does compiler compiles this codes OK if they do not match in style?
Don't use this _PROTOTYPE macro. Actually, you can safely delete everything between #if 0 and #endif.
Don't use non-ANSI compilers either -- it's 2012 now, not 1982.
Do use [code] and [/code] tags.
PS: the old-style function-parameter-definition is still usable, but obsolete.
The code is from i think around 1985. since I'm re-writing the old code, I'm not gonna use the _PROTOTYPE macro but I still do need to understand how things work.
I'll appreciate if someone takes a time and explains this.
> I have two questions.
> The function prototype is ansi style and function definition is K&R style how does compiler compiles this codes OK if they do not match in style?
There is nothing preventing using both styles, but in new programs you shouldn't use old style.
> How do you use _PROTOTYPE macro?
You don't. You see it is between #if 0 and #endif, meaning: 'dear compiler, ignore this part'
> Do you have any questions I haven't answered yet?
No.. I thank you for answering it, appreciate it
>> How do you use _PROTOTYPE macro?
> You don't. You see it is between #if 0 and #endif, meaning: 'dear compiler, ignore this part'
.. I quoted with #if 0, #endif to see the effect. and put ansi style prototype. I was surprised to see the source was compiled without any errors.
I guess what I was expecting was more like there is this kind of macro code somewhere else then that expands above code and it has effect of resulting such such... then it compiles the above code without any errors
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.