Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Re: identifier scope in old-style declarations

Reply
Thread Tools

Re: identifier scope in old-style declarations

 
 
Harald van Dijk
Guest
Posts: n/a
 
      08-06-2008
On Wed, 06 Aug 2008 13:28:04 -0700, Keith Thompson wrote:
> santosh <(E-Mail Removed)> writes: [...]
>> A conforming implementation could insert it's own main
>> and invoke man from it.

>
> An implementation is specifically forbidden to declare a prototype for
> main (C99 5.1.2.2.1p1); that includes a prototype that's part of a
> definition. Conceivably an implementation could provide a
> non-prototyped definition, but that would be silly.


I suspect 5.1.2.2.1p1 is meant to allow both
int main(void)
and
int main(int, char *[])
where one or the other would be rejected if the implementation predeclares
main with a prototype. If santosh meant that an implementation can insert
its own main function as if it's defined in a separate translation unit,
then its effect is identical whether the definition includes a prototype
or not, and since the unprototyped version is not forbidden, the as-if
rule also allows the prototyped version.
 
Reply With Quote
 
 
 
 
santosh
Guest
Posts: n/a
 
      08-07-2008
Keith Thompson wrote:

> santosh <(E-Mail Removed)> writes:
> [...]
>>> Eric Sosman wrote:

> [...]
>>>> For example, how would you describe the error in
>>>>
>>>> #include <stdio.h>
>>>> int man(void) {
>>>> return puts ("Hello, world!\n") == EOF;
>>>> }
>>>>
>>>> ? (Yes, this is a trick question.)

> [...]
>> Just to followup, many knowledgeable members of this group have
>> previously said that an implementation is not required to reject the
>> translation of any program that does not contain a selected #error
>> directive.

>
> Right.
>
>> In light of that I would amend my answer above and say that
>> no error need be emitted by a compiler for the translation unit given
>> above by Eric.

>
> Compilers don't emit errors; they emit diagnostic messages.


Yes.

<snip>

>> A conforming implementation could insert it's own main and invoke man
>> from it.

>
> An implementation is specifically forbidden to declare a prototype for
> main (C99 5.1.2.2.1p1); that includes a prototype that's part of a
> definition. Conceivably an implementation could provide a
> non-prototyped definition, but that would be silly.


Ah, OK.

> On the other hand, some tool in the environment (that's not considered
> part of the C implementation) could always provide a definition for
> main. Typically that tool is a text editor that you use to write your
> own definition of main, but it could be something else.


Right. The post was just a bit of nitpicking, and it appears that I'm
not up to scratch yet.

 
Reply With Quote
 
 
 
 
vippstar@gmail.com
Guest
Posts: n/a
 
      08-07-2008
On Aug 6, 9:41 pm, "Mark B [Diputsur]" <(E-Mail Removed)> wrote:
> "Huibert Bol" <(E-Mail Removed)> wrote in message
>
> news:g7cqut$9qc$(E-Mail Removed)...
>
> > Eric Sosman wrote:

>
> >> For example, how would you describe the error in

>
> >> #include <stdio.h>
> >> int man(void) {
> >> return puts ("Hello, world!\n") == EOF;
> >> }

>
> >> ? (Yes, this is a trick question.)

>
> > It prints an additional newline

>
> Doubtful it will print anything...
> it's missing the function called at program startup.


What are you talking about?
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
XSD Error: "Expecting '.', identifier or quoted identifier withmultiple tables. S_K ASP .Net 0 08-06-2008 09:22 PM
the static identifier in the global scope parag_paul@hotmail.com C Programming 1 04-11-2008 08:57 AM
How can I fix the warning C4786 'identifier' : identifier wastruncated to 'number' characters in the debug information...? babakandme@yahoo.com C++ 2 12-11-2007 08:17 PM
identifier not found error, undeclared identifier aarthi28@gmail.com C++ 2 02-26-2007 02:11 AM
Trying to declare identifier locally and hide a file scope identifier Kobu C Programming 7 02-25-2005 05:19 AM



Advertisments