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