473,320 Members | 1,965 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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.
Jun 27 '08 #1
3 1276
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.
Jun 27 '08 #2
vi******@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
Jun 27 '08 #3
vi******@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
Jun 27 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

205
by: Jeremy Siek | last post by:
CALL FOR PAPERS/PARTICIPATION C++, Boost, and the Future of C++ Libraries Workshop at OOPSLA October 24-28, 2004 Vancouver, British Columbia, Canada http://tinyurl.com/4n5pf Submissions
13
by: seemanta dutta | last post by:
Greetings C gurus, I have used preprocessor directives since a very long time. But whenever I see some professional piece of C code, the linux kernel for example, I get literally confused by the...
13
by: Chris Croughton | last post by:
Is the following code standard-compliant, and if so what should it do? And where in the standard defines the behaviour? #include <stdio.h> #define DEF defined XXX int main(void) { int...
2
by: Paolo | last post by:
I imported a VC++6.0 project into VC++7.1. The conversion operation makes a mess with Preprocessor Definitions, adding a "$(NoInherit)" for each file. For example: I had a DLL project in VC++6.0...
2
by: Prashant Mahajan | last post by:
I just wanted comments from you all on the following topic: Let's say we have 2, C code files namely file1.c and file2.c. file1.c contains few pre-processor definations say #define TEST1 10 We...
1
by: Frank-René Schäfer | last post by:
Is there a way to write code like #include IMPLEMENT_THIS(my_class, my_member_type) for what looks currently like #define __C my_class #define __MT my_member_type #include...
8
by: claus.tondering | last post by:
I need to write a macro that inserts someStruct m_someStruct; into another struct declaration. The problem is that if the programmer specifies one particluar struct (called alpha), nothing...
6
by: olivier.grant | last post by:
Hi All, I'm trying to define a macro that will allow me to write the following code : #include MY_MACRO( NAME, SPACE ) and end up with the following preprocessed code : #include NAME.hpp
3
by: Nathan Moinvaziri | last post by:
I am wonder if there is a way to use preprocessor definitions to expose code only if a particular file is included in a project. I am targeting the msvc. I am thinking of something like #if...
14
by: lagman | last post by:
All, I'm looking for a tool that is able to take my code base (which is full of preprocessor directives) and spit out source code that is "clean" of any preprocessor directives based on the...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.