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 > preprocessor #include
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
preprocessor #include

Réponse
 
LinkBack Outils de la discussion
Vieux 02/06/2008, 13h40   #1
vippstar@gmail.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut preprocessor #include

Is this a valid implementation of stdio.h?

-- stdio.h --
#ifndef __STDIO_H
#define __STDIO_H
/* all the necessary declarations etc */

void __dummy(void);
void __dummy(void) { return;
#include "closebracket.h"
#endif /* __STDIO_H */
-- stdio.h --

-- closebracket.h --
}
-- closebracket.h --

And if this is valid, how many files can stdio.h include and remain to
be valid?
5.2.4.1 mentions a requirement of at least 15 nesting levels of
#included files.
Is it the sum of both the implementations inclusions and the
programmers inclusions? And if so, does that mean the programmer
cannot portably have more than 1 nesting level, since the
implementation is free to use 62 nesting levels?

Thanks for all the replies.
  Réponse avec citation
Vieux 02/06/2008, 13h45   #2
vippstar@gmail.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: preprocessor #include

On Jun 2, 3:40 pm, vipps...@gmail.com wrote:
> And if this is valid, how many files can stdio.h include and remain to
> be valid?
> 5.2.4.1 mentions a requirement of at least 15 nesting levels of
> #included files.
> Is it the sum of both the implementations inclusions and the
> programmers inclusions? And if so, does that mean the programmer
> cannot portably have more than 1 nesting level, since the
> implementation is free to use 62 nesting levels?

Whoops, 14 nesting levels.
  Réponse avec citation
Vieux 02/06/2008, 14h24   #3
pete
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: preprocessor #include

vippstar@gmail.com wrote:
> Is this a valid implementation of stdio.h?
>
> -- stdio.h --
> #ifndef __STDIO_H
> #define __STDIO_H
> /* all the necessary declarations etc */
>
> void __dummy(void);
> void __dummy(void) { return;
> #include "closebracket.h"
> #endif /* __STDIO_H */
> -- stdio.h --
>
> -- closebracket.h --
> }
> -- closebracket.h --
>
> And if this is valid, how many files can stdio.h include and remain to
> be valid?
> 5.2.4.1 mentions a requirement of at least 15 nesting levels of
> #included files.
> Is it the sum of both the implementations inclusions and the
> programmers inclusions?


No.
What it says, applies to programs.

5.2.4.1 Translation limits

[#1] The implementation shall be able to translate and
execute at least one program that contains at least one
instance of every one of the following limits:

The text of an implementation's headers isn't part of a C program.

N869
5.1 Conceptual models
5.1.1 Translation environment
5.1.1.1 Program structure
[#1] A C program need not all be translated at the same
time. The text of the program is kept in units called
source files, (or preprocessing files) in this International
Standard. A source file together with all the headers and
source files included via the preprocessing directive
#include is known as a preprocessing translation unit. After
preprocessing, a preprocessing translation unit is called a
translation unit. Previously translated translation units
may be preserved individually or in libraries. The separate
translation units of a program communicate by (for example)
calls to functions whose identifiers have external linkage,
manipulation of objects whose identifiers have external
linkage, or manipulation of data files. Translation units
may be separately translated and then later linked to
produce an executable program.

--
pete
  Réponse avec citation
Vieux 03/06/2008, 03h50   #4
Thad Smith
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: preprocessor #include

vippstar@gmail.com wrote:
> On Jun 2, 3:40 pm, vipps...@gmail.com wrote:
>> And if this is valid, how many files can stdio.h include and remain to
>> be valid?
>> 5.2.4.1 mentions a requirement of at least 15 nesting levels of
>> #included files.
>> Is it the sum of both the implementations inclusions and the
>> programmers inclusions? And if so, does that mean the programmer
>> cannot portably have more than 1 nesting level, since the
>> implementation is free to use 62 nesting levels?

> Whoops, 14 nesting levels.


Since the user doesn't have control over the nesting levels of system
headers, I interpret the constraint to mean that the user can nest 14
#include files, then #include any system header.

As the implementor, you can nest the system headers as deeply as you like,
as long as you can accommodate the limit, with system header counting as
one level.

--
Thad
  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 03h48.


É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,12579 seconds with 12 queries