Unix Programming - void context

This is Interesting: Free IT Magazines  
Home > Archive > Unix Programming > February 2004 > void context





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author void context
Gabe

2004-02-16, 2:34 pm

Hello all.

Out of curiousity I was wondering why it is that there are some
functions that one would call and state specifically the void, as in

int main(void) ... (this does *not* cause compiler errors)


whereas there are many other "void" functions that one should not
specifically name the void, as in

pid_t fork(void) ... (this causes compiler errors)

This seems to be inconsistent. I have heard that it is considered
good programming style to declare main as above (if that is what you
need, of course) but the same style causes errors in other situations.
I am new enough to unix programming that the answer does not seem at
all obvious, so if anyone could shed some light on the situation, I
would appreciate it.

Many thanks,

Gabe
Barry Margolin

2004-02-16, 3:33 pm

In article <d069c869.0402162002.68210426@posting.google.com>,
jgschenz@yahoo.com (Gabe) wrote:

> Hello all.
>
> Out of curiousity I was wondering why it is that there are some
> functions that one would call and state specifically the void, as in
>
> int main(void) ... (this does *not* cause compiler errors)
>
>
> whereas there are many other "void" functions that one should not
> specifically name the void, as in
>
> pid_t fork(void) ... (this causes compiler errors)


This function is probably already declared in a header that you're
#include'ing, and your program is re-declaring it differently. The
declaration in the header is probably

pid_t fork();

for backward compatibility with pre-ANSI programs.

--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com