Header file that includes all standard C library headersReverse all lines in a fileMakefile and main header...

Visiting the UK as unmarried couple

What if somebody invests in my application?

Identify a stage play about a VR experience in which participants are encouraged to simulate performing horrific activities

Did US corporations pay demonstrators in the German demonstrations against article 13?

A known event to a history junkie

Why are all the doors on Ferenginar (the Ferengi home world) far shorter than the average Ferengi?

What should I use for Mishna study?

Is it okay / does it make sense for another player to join a running game of Munchkin?

Lightning Web Component - do I need to track changes for every single input field in a form

The One-Electron Universe postulate is true - what simple change can I make to change the whole universe?

Have I saved too much for retirement so far?

Why are on-board computers allowed to change controls without notifying the pilots?

How do ultrasonic sensors differentiate between transmitted and received signals?

Is there an Impartial Brexit Deal comparison site?

Why isn't KTEX's runway designation 10/28 instead of 9/27?

How to check participants in at events?

Reply ‘no position’ while the job posting is still there (‘HiWi’ position in Germany)

What was required to accept "troll"?

How to deal with or prevent idle in the test team?

Resetting two CD4017 counters simultaneously, only one resets

Can a Gentile theist be saved?

A workplace installs custom certificates on personal devices, can this be used to decrypt HTTPS traffic?

Can the electrostatic force be infinite in magnitude?

Simple recursive Sudoku solver



Header file that includes all standard C library headers


Reverse all lines in a fileMakefile and main header file for a shellLibrary for manipulation of binary protocol headersStandard way of reading file contents to a bufferShort header file for safe CLI input handling in CImplementation of C Standard Library Function ntohl()Sending instructions to an LCD display controlled by HD44780C library for standard input operations with data validation and error checkPortability in using up-and-coming library featuresPortably get one character from standard input using standard library only













2












$begingroup$


The Standard C Library consists of various headers files. Often only a few select ones are needed for given code.



Other times it is simply convenient coding to include them all in a .c file, even if that make the compilation time a bit slower.



Including all standard <*.h> is useful to help detect naming collisions of a .c file with an existing standard function, object, type, macro, etc.



Review Goal



How well does std.h accomplish the goal of including all standard header files via one .h file given that the set varies amongst C versions and implementations?



/*
* std.h
* Created on: Mar 16, 2019, Author: chux
*/

#ifndef STD_H_
#define STD_H_

#include <assert.h>
#include <ctype.h>
#include <errno.h>
#include <float.h>
#include <limits.h>
#include <locale.h>
#include <math.h>
#include <setjmp.h>
#include <signal.h>
#include <stdarg.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

#if defined __STDC__ && defined __STDC_VERSION__

#if __STDC_VERSION__ >= 199409
#include <iso646.h>
#include <wchar.h>
#include <wctype.h>
#endif

#if __STDC_VERSION__ >= 199901
#ifndef __STDC_NO_COMPLEX__
#include <complex.h>
#endif
#include <fenv.h>
#include <inttypes.h>
#include <stdbool.h>
#include <stdint.h>
#include <tgmath.h>
#endif

#if __STDC_VERSION__ >= 201112
#include <stdalign.h>
#ifndef __STDC_NO_ATOMICS__
#include <stdatomic.h>
#endif
#include <stdnoreturn.h>
#ifndef __STDC_NO_THREADS__
#include <threads.h>
#endif
#include <uchar.h>
#endif

#if __STDC_VERSION__ >= 201710
/* None added */
#endif

#endif

#endif /* STD_H_ */




In making a set of functions and types called say foo, I do not recommend including all header files in a foo.h, yet perhaps in foo.c.



Sample usage



// foo.h  (no std.h here)
#ifndef FOO_H_
#define FOO_H_

#include <stdint.h>
#include <time.h>

typedef struct {
time_t t;
uint32_t u32;
} foo;

void foo_this(foo *f);
void foo_that(foo *f);

#endif /* FOO_H_ */


foo.c or main.c



#include "foo.h"
#include "std.h"

int main(void) {
foo f;
foo_this(&f);
foo_that(&f);
printf("Hello World!n");
return 0;
}




The alternative spellings afforded in <iso646.h> seem to be a solution to a regional character set problem of years ago. I reluctantly included <iso646.h> here but do see that a good candidate to exclude. It defines macros for and, or, xor and others.










share|improve this question











$endgroup$












  • $begingroup$
    When I read the title, I thought "but why?" Having read the description, I see what you're doing. However, beware that that if you contravene the naming rules - which I'm sure you don't - then finding no collisions using this compiler, today doesn't guarantee anything about other builds. Past success is no guarantee of future performance!
    $endgroup$
    – Toby Speight
    15 hours ago












  • $begingroup$
    @TobySpeight Agree the including all <*.h> will not certainly detect all name collision and future ones, yet is a reasonable test today to potential discern them.
    $endgroup$
    – chux
    15 hours ago
















2












$begingroup$


The Standard C Library consists of various headers files. Often only a few select ones are needed for given code.



Other times it is simply convenient coding to include them all in a .c file, even if that make the compilation time a bit slower.



Including all standard <*.h> is useful to help detect naming collisions of a .c file with an existing standard function, object, type, macro, etc.



Review Goal



How well does std.h accomplish the goal of including all standard header files via one .h file given that the set varies amongst C versions and implementations?



/*
* std.h
* Created on: Mar 16, 2019, Author: chux
*/

#ifndef STD_H_
#define STD_H_

#include <assert.h>
#include <ctype.h>
#include <errno.h>
#include <float.h>
#include <limits.h>
#include <locale.h>
#include <math.h>
#include <setjmp.h>
#include <signal.h>
#include <stdarg.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

#if defined __STDC__ && defined __STDC_VERSION__

#if __STDC_VERSION__ >= 199409
#include <iso646.h>
#include <wchar.h>
#include <wctype.h>
#endif

#if __STDC_VERSION__ >= 199901
#ifndef __STDC_NO_COMPLEX__
#include <complex.h>
#endif
#include <fenv.h>
#include <inttypes.h>
#include <stdbool.h>
#include <stdint.h>
#include <tgmath.h>
#endif

#if __STDC_VERSION__ >= 201112
#include <stdalign.h>
#ifndef __STDC_NO_ATOMICS__
#include <stdatomic.h>
#endif
#include <stdnoreturn.h>
#ifndef __STDC_NO_THREADS__
#include <threads.h>
#endif
#include <uchar.h>
#endif

#if __STDC_VERSION__ >= 201710
/* None added */
#endif

#endif

#endif /* STD_H_ */




In making a set of functions and types called say foo, I do not recommend including all header files in a foo.h, yet perhaps in foo.c.



Sample usage



// foo.h  (no std.h here)
#ifndef FOO_H_
#define FOO_H_

#include <stdint.h>
#include <time.h>

typedef struct {
time_t t;
uint32_t u32;
} foo;

void foo_this(foo *f);
void foo_that(foo *f);

#endif /* FOO_H_ */


foo.c or main.c



#include "foo.h"
#include "std.h"

int main(void) {
foo f;
foo_this(&f);
foo_that(&f);
printf("Hello World!n");
return 0;
}




The alternative spellings afforded in <iso646.h> seem to be a solution to a regional character set problem of years ago. I reluctantly included <iso646.h> here but do see that a good candidate to exclude. It defines macros for and, or, xor and others.










share|improve this question











$endgroup$












  • $begingroup$
    When I read the title, I thought "but why?" Having read the description, I see what you're doing. However, beware that that if you contravene the naming rules - which I'm sure you don't - then finding no collisions using this compiler, today doesn't guarantee anything about other builds. Past success is no guarantee of future performance!
    $endgroup$
    – Toby Speight
    15 hours ago












  • $begingroup$
    @TobySpeight Agree the including all <*.h> will not certainly detect all name collision and future ones, yet is a reasonable test today to potential discern them.
    $endgroup$
    – chux
    15 hours ago














2












2








2





$begingroup$


The Standard C Library consists of various headers files. Often only a few select ones are needed for given code.



Other times it is simply convenient coding to include them all in a .c file, even if that make the compilation time a bit slower.



Including all standard <*.h> is useful to help detect naming collisions of a .c file with an existing standard function, object, type, macro, etc.



Review Goal



How well does std.h accomplish the goal of including all standard header files via one .h file given that the set varies amongst C versions and implementations?



/*
* std.h
* Created on: Mar 16, 2019, Author: chux
*/

#ifndef STD_H_
#define STD_H_

#include <assert.h>
#include <ctype.h>
#include <errno.h>
#include <float.h>
#include <limits.h>
#include <locale.h>
#include <math.h>
#include <setjmp.h>
#include <signal.h>
#include <stdarg.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

#if defined __STDC__ && defined __STDC_VERSION__

#if __STDC_VERSION__ >= 199409
#include <iso646.h>
#include <wchar.h>
#include <wctype.h>
#endif

#if __STDC_VERSION__ >= 199901
#ifndef __STDC_NO_COMPLEX__
#include <complex.h>
#endif
#include <fenv.h>
#include <inttypes.h>
#include <stdbool.h>
#include <stdint.h>
#include <tgmath.h>
#endif

#if __STDC_VERSION__ >= 201112
#include <stdalign.h>
#ifndef __STDC_NO_ATOMICS__
#include <stdatomic.h>
#endif
#include <stdnoreturn.h>
#ifndef __STDC_NO_THREADS__
#include <threads.h>
#endif
#include <uchar.h>
#endif

#if __STDC_VERSION__ >= 201710
/* None added */
#endif

#endif

#endif /* STD_H_ */




In making a set of functions and types called say foo, I do not recommend including all header files in a foo.h, yet perhaps in foo.c.



Sample usage



// foo.h  (no std.h here)
#ifndef FOO_H_
#define FOO_H_

#include <stdint.h>
#include <time.h>

typedef struct {
time_t t;
uint32_t u32;
} foo;

void foo_this(foo *f);
void foo_that(foo *f);

#endif /* FOO_H_ */


foo.c or main.c



#include "foo.h"
#include "std.h"

int main(void) {
foo f;
foo_this(&f);
foo_that(&f);
printf("Hello World!n");
return 0;
}




The alternative spellings afforded in <iso646.h> seem to be a solution to a regional character set problem of years ago. I reluctantly included <iso646.h> here but do see that a good candidate to exclude. It defines macros for and, or, xor and others.










share|improve this question











$endgroup$




The Standard C Library consists of various headers files. Often only a few select ones are needed for given code.



Other times it is simply convenient coding to include them all in a .c file, even if that make the compilation time a bit slower.



Including all standard <*.h> is useful to help detect naming collisions of a .c file with an existing standard function, object, type, macro, etc.



Review Goal



How well does std.h accomplish the goal of including all standard header files via one .h file given that the set varies amongst C versions and implementations?



/*
* std.h
* Created on: Mar 16, 2019, Author: chux
*/

#ifndef STD_H_
#define STD_H_

#include <assert.h>
#include <ctype.h>
#include <errno.h>
#include <float.h>
#include <limits.h>
#include <locale.h>
#include <math.h>
#include <setjmp.h>
#include <signal.h>
#include <stdarg.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

#if defined __STDC__ && defined __STDC_VERSION__

#if __STDC_VERSION__ >= 199409
#include <iso646.h>
#include <wchar.h>
#include <wctype.h>
#endif

#if __STDC_VERSION__ >= 199901
#ifndef __STDC_NO_COMPLEX__
#include <complex.h>
#endif
#include <fenv.h>
#include <inttypes.h>
#include <stdbool.h>
#include <stdint.h>
#include <tgmath.h>
#endif

#if __STDC_VERSION__ >= 201112
#include <stdalign.h>
#ifndef __STDC_NO_ATOMICS__
#include <stdatomic.h>
#endif
#include <stdnoreturn.h>
#ifndef __STDC_NO_THREADS__
#include <threads.h>
#endif
#include <uchar.h>
#endif

#if __STDC_VERSION__ >= 201710
/* None added */
#endif

#endif

#endif /* STD_H_ */




In making a set of functions and types called say foo, I do not recommend including all header files in a foo.h, yet perhaps in foo.c.



Sample usage



// foo.h  (no std.h here)
#ifndef FOO_H_
#define FOO_H_

#include <stdint.h>
#include <time.h>

typedef struct {
time_t t;
uint32_t u32;
} foo;

void foo_this(foo *f);
void foo_that(foo *f);

#endif /* FOO_H_ */


foo.c or main.c



#include "foo.h"
#include "std.h"

int main(void) {
foo f;
foo_this(&f);
foo_that(&f);
printf("Hello World!n");
return 0;
}




The alternative spellings afforded in <iso646.h> seem to be a solution to a regional character set problem of years ago. I reluctantly included <iso646.h> here but do see that a good candidate to exclude. It defines macros for and, or, xor and others.







c portability






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited yesterday









200_success

130k17155419




130k17155419










asked yesterday









chuxchux

13.5k21345




13.5k21345












  • $begingroup$
    When I read the title, I thought "but why?" Having read the description, I see what you're doing. However, beware that that if you contravene the naming rules - which I'm sure you don't - then finding no collisions using this compiler, today doesn't guarantee anything about other builds. Past success is no guarantee of future performance!
    $endgroup$
    – Toby Speight
    15 hours ago












  • $begingroup$
    @TobySpeight Agree the including all <*.h> will not certainly detect all name collision and future ones, yet is a reasonable test today to potential discern them.
    $endgroup$
    – chux
    15 hours ago


















  • $begingroup$
    When I read the title, I thought "but why?" Having read the description, I see what you're doing. However, beware that that if you contravene the naming rules - which I'm sure you don't - then finding no collisions using this compiler, today doesn't guarantee anything about other builds. Past success is no guarantee of future performance!
    $endgroup$
    – Toby Speight
    15 hours ago












  • $begingroup$
    @TobySpeight Agree the including all <*.h> will not certainly detect all name collision and future ones, yet is a reasonable test today to potential discern them.
    $endgroup$
    – chux
    15 hours ago
















$begingroup$
When I read the title, I thought "but why?" Having read the description, I see what you're doing. However, beware that that if you contravene the naming rules - which I'm sure you don't - then finding no collisions using this compiler, today doesn't guarantee anything about other builds. Past success is no guarantee of future performance!
$endgroup$
– Toby Speight
15 hours ago






$begingroup$
When I read the title, I thought "but why?" Having read the description, I see what you're doing. However, beware that that if you contravene the naming rules - which I'm sure you don't - then finding no collisions using this compiler, today doesn't guarantee anything about other builds. Past success is no guarantee of future performance!
$endgroup$
– Toby Speight
15 hours ago














$begingroup$
@TobySpeight Agree the including all <*.h> will not certainly detect all name collision and future ones, yet is a reasonable test today to potential discern them.
$endgroup$
– chux
15 hours ago




$begingroup$
@TobySpeight Agree the including all <*.h> will not certainly detect all name collision and future ones, yet is a reasonable test today to potential discern them.
$endgroup$
– chux
15 hours ago










2 Answers
2






active

oldest

votes


















0












$begingroup$

With this suggested usage:




#include "foo.h"
#include "std.h"



then any macros defined in "std.h" (and not used in the rest of the main) won't break the program. Swapping these round:



#include "std.h"
#include "foo.h"


solves that problem, but then fails to diagnose missing includes in "foo.h".






share|improve this answer









$endgroup$





















    0












    $begingroup$



    • Your code doesn't cover "freestanding implementations" (embedded systems or OS). You could check for #if __STDC_HOSTED__ == 0 and reduce the headers. Freestanding implementations need not provide all headers except a minimal subset, see C11 4/6:




      A conforming freestanding implementation shall accept any strictly conforming program in which the
      use of the features specified in the library clause (clause 7) is confined to the contents of the standard headers <float.h>, <iso646.h>, <limits.h>, <stdalign.h>, <stdarg.h>, <stdbool.h>, <stddef.h>, <stdint.h>, and
      <stdnoreturn.h>




      Though of course freestanding implementations may provide other headers too, making this hard to fulfil without a specific implementation in mind.



    • Style issue: you should indent everything within #if... #endif just as you would for regular if statements. It is also good practice to leave a comment /* */ after each #endif to document which #if is belongs to.



    EDIT: proposed indention fix



    #ifndef STD_H_
    #define STD_H_

    #include <assert.h>
    #include <ctype.h>
    #include <errno.h>
    #include <float.h>
    #include <limits.h>
    #include <locale.h>
    #include <math.h>
    #include <setjmp.h>
    #include <signal.h>
    #include <stdarg.h>
    #include <stddef.h>
    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    #include <time.h>

    #if defined __STDC__ && defined __STDC_VERSION__

    #if __STDC_VERSION__ >= 199409
    #include <iso646.h>
    #include <wchar.h>
    #include <wctype.h>
    #endif

    #if __STDC_VERSION__ >= 199901
    #ifndef __STDC_NO_COMPLEX__
    #include <complex.h>
    #endif
    #include <fenv.h>
    #include <inttypes.h>
    #include <stdbool.h>
    #include <stdint.h>
    #include <tgmath.h>
    #endif

    #if __STDC_VERSION__ >= 201112
    #include <stdalign.h>
    #ifndef __STDC_NO_ATOMICS__
    #include <stdatomic.h>
    #endif
    #include <stdnoreturn.h>
    #ifndef __STDC_NO_THREADS__
    #include <threads.h>
    #endif
    #include <uchar.h>
    #endif

    #if __STDC_VERSION__ >= 201710
    /* None added */
    #endif

    #endif /* #if defined __STDC__ && defined __STDC_VERSION__ */

    #endif /* STD_H_ */





    share|improve this answer











    $endgroup$













    • $begingroup$
      Please post a sample # indent. I have tried various styles, ` #if bar` (my auto formatter (Eclipse) keeps shifting them left ) and # if bar which looks odd. Perhaps you have another?
      $endgroup$
      – chux
      14 hours ago










    • $begingroup$
      @chux Posted. After trying some 30+ different, magic IDEs including GNU indent, I'm convinced that mankind will never develop intelligent AI. So I tend to fall back to good ole spacebar :)
      $endgroup$
      – Lundin
      13 hours ago











    Your Answer





    StackExchange.ifUsing("editor", function () {
    return StackExchange.using("mathjaxEditing", function () {
    StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
    StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["\$", "\$"]]);
    });
    });
    }, "mathjax-editing");

    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "196"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f216119%2fheader-file-that-includes-all-standard-c-library-headers%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0












    $begingroup$

    With this suggested usage:




    #include "foo.h"
    #include "std.h"



    then any macros defined in "std.h" (and not used in the rest of the main) won't break the program. Swapping these round:



    #include "std.h"
    #include "foo.h"


    solves that problem, but then fails to diagnose missing includes in "foo.h".






    share|improve this answer









    $endgroup$


















      0












      $begingroup$

      With this suggested usage:




      #include "foo.h"
      #include "std.h"



      then any macros defined in "std.h" (and not used in the rest of the main) won't break the program. Swapping these round:



      #include "std.h"
      #include "foo.h"


      solves that problem, but then fails to diagnose missing includes in "foo.h".






      share|improve this answer









      $endgroup$
















        0












        0








        0





        $begingroup$

        With this suggested usage:




        #include "foo.h"
        #include "std.h"



        then any macros defined in "std.h" (and not used in the rest of the main) won't break the program. Swapping these round:



        #include "std.h"
        #include "foo.h"


        solves that problem, but then fails to diagnose missing includes in "foo.h".






        share|improve this answer









        $endgroup$



        With this suggested usage:




        #include "foo.h"
        #include "std.h"



        then any macros defined in "std.h" (and not used in the rest of the main) won't break the program. Swapping these round:



        #include "std.h"
        #include "foo.h"


        solves that problem, but then fails to diagnose missing includes in "foo.h".







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered 15 hours ago









        Toby SpeightToby Speight

        26.6k742118




        26.6k742118

























            0












            $begingroup$



            • Your code doesn't cover "freestanding implementations" (embedded systems or OS). You could check for #if __STDC_HOSTED__ == 0 and reduce the headers. Freestanding implementations need not provide all headers except a minimal subset, see C11 4/6:




              A conforming freestanding implementation shall accept any strictly conforming program in which the
              use of the features specified in the library clause (clause 7) is confined to the contents of the standard headers <float.h>, <iso646.h>, <limits.h>, <stdalign.h>, <stdarg.h>, <stdbool.h>, <stddef.h>, <stdint.h>, and
              <stdnoreturn.h>




              Though of course freestanding implementations may provide other headers too, making this hard to fulfil without a specific implementation in mind.



            • Style issue: you should indent everything within #if... #endif just as you would for regular if statements. It is also good practice to leave a comment /* */ after each #endif to document which #if is belongs to.



            EDIT: proposed indention fix



            #ifndef STD_H_
            #define STD_H_

            #include <assert.h>
            #include <ctype.h>
            #include <errno.h>
            #include <float.h>
            #include <limits.h>
            #include <locale.h>
            #include <math.h>
            #include <setjmp.h>
            #include <signal.h>
            #include <stdarg.h>
            #include <stddef.h>
            #include <stdio.h>
            #include <stdlib.h>
            #include <string.h>
            #include <time.h>

            #if defined __STDC__ && defined __STDC_VERSION__

            #if __STDC_VERSION__ >= 199409
            #include <iso646.h>
            #include <wchar.h>
            #include <wctype.h>
            #endif

            #if __STDC_VERSION__ >= 199901
            #ifndef __STDC_NO_COMPLEX__
            #include <complex.h>
            #endif
            #include <fenv.h>
            #include <inttypes.h>
            #include <stdbool.h>
            #include <stdint.h>
            #include <tgmath.h>
            #endif

            #if __STDC_VERSION__ >= 201112
            #include <stdalign.h>
            #ifndef __STDC_NO_ATOMICS__
            #include <stdatomic.h>
            #endif
            #include <stdnoreturn.h>
            #ifndef __STDC_NO_THREADS__
            #include <threads.h>
            #endif
            #include <uchar.h>
            #endif

            #if __STDC_VERSION__ >= 201710
            /* None added */
            #endif

            #endif /* #if defined __STDC__ && defined __STDC_VERSION__ */

            #endif /* STD_H_ */





            share|improve this answer











            $endgroup$













            • $begingroup$
              Please post a sample # indent. I have tried various styles, ` #if bar` (my auto formatter (Eclipse) keeps shifting them left ) and # if bar which looks odd. Perhaps you have another?
              $endgroup$
              – chux
              14 hours ago










            • $begingroup$
              @chux Posted. After trying some 30+ different, magic IDEs including GNU indent, I'm convinced that mankind will never develop intelligent AI. So I tend to fall back to good ole spacebar :)
              $endgroup$
              – Lundin
              13 hours ago
















            0












            $begingroup$



            • Your code doesn't cover "freestanding implementations" (embedded systems or OS). You could check for #if __STDC_HOSTED__ == 0 and reduce the headers. Freestanding implementations need not provide all headers except a minimal subset, see C11 4/6:




              A conforming freestanding implementation shall accept any strictly conforming program in which the
              use of the features specified in the library clause (clause 7) is confined to the contents of the standard headers <float.h>, <iso646.h>, <limits.h>, <stdalign.h>, <stdarg.h>, <stdbool.h>, <stddef.h>, <stdint.h>, and
              <stdnoreturn.h>




              Though of course freestanding implementations may provide other headers too, making this hard to fulfil without a specific implementation in mind.



            • Style issue: you should indent everything within #if... #endif just as you would for regular if statements. It is also good practice to leave a comment /* */ after each #endif to document which #if is belongs to.



            EDIT: proposed indention fix



            #ifndef STD_H_
            #define STD_H_

            #include <assert.h>
            #include <ctype.h>
            #include <errno.h>
            #include <float.h>
            #include <limits.h>
            #include <locale.h>
            #include <math.h>
            #include <setjmp.h>
            #include <signal.h>
            #include <stdarg.h>
            #include <stddef.h>
            #include <stdio.h>
            #include <stdlib.h>
            #include <string.h>
            #include <time.h>

            #if defined __STDC__ && defined __STDC_VERSION__

            #if __STDC_VERSION__ >= 199409
            #include <iso646.h>
            #include <wchar.h>
            #include <wctype.h>
            #endif

            #if __STDC_VERSION__ >= 199901
            #ifndef __STDC_NO_COMPLEX__
            #include <complex.h>
            #endif
            #include <fenv.h>
            #include <inttypes.h>
            #include <stdbool.h>
            #include <stdint.h>
            #include <tgmath.h>
            #endif

            #if __STDC_VERSION__ >= 201112
            #include <stdalign.h>
            #ifndef __STDC_NO_ATOMICS__
            #include <stdatomic.h>
            #endif
            #include <stdnoreturn.h>
            #ifndef __STDC_NO_THREADS__
            #include <threads.h>
            #endif
            #include <uchar.h>
            #endif

            #if __STDC_VERSION__ >= 201710
            /* None added */
            #endif

            #endif /* #if defined __STDC__ && defined __STDC_VERSION__ */

            #endif /* STD_H_ */





            share|improve this answer











            $endgroup$













            • $begingroup$
              Please post a sample # indent. I have tried various styles, ` #if bar` (my auto formatter (Eclipse) keeps shifting them left ) and # if bar which looks odd. Perhaps you have another?
              $endgroup$
              – chux
              14 hours ago










            • $begingroup$
              @chux Posted. After trying some 30+ different, magic IDEs including GNU indent, I'm convinced that mankind will never develop intelligent AI. So I tend to fall back to good ole spacebar :)
              $endgroup$
              – Lundin
              13 hours ago














            0












            0








            0





            $begingroup$



            • Your code doesn't cover "freestanding implementations" (embedded systems or OS). You could check for #if __STDC_HOSTED__ == 0 and reduce the headers. Freestanding implementations need not provide all headers except a minimal subset, see C11 4/6:




              A conforming freestanding implementation shall accept any strictly conforming program in which the
              use of the features specified in the library clause (clause 7) is confined to the contents of the standard headers <float.h>, <iso646.h>, <limits.h>, <stdalign.h>, <stdarg.h>, <stdbool.h>, <stddef.h>, <stdint.h>, and
              <stdnoreturn.h>




              Though of course freestanding implementations may provide other headers too, making this hard to fulfil without a specific implementation in mind.



            • Style issue: you should indent everything within #if... #endif just as you would for regular if statements. It is also good practice to leave a comment /* */ after each #endif to document which #if is belongs to.



            EDIT: proposed indention fix



            #ifndef STD_H_
            #define STD_H_

            #include <assert.h>
            #include <ctype.h>
            #include <errno.h>
            #include <float.h>
            #include <limits.h>
            #include <locale.h>
            #include <math.h>
            #include <setjmp.h>
            #include <signal.h>
            #include <stdarg.h>
            #include <stddef.h>
            #include <stdio.h>
            #include <stdlib.h>
            #include <string.h>
            #include <time.h>

            #if defined __STDC__ && defined __STDC_VERSION__

            #if __STDC_VERSION__ >= 199409
            #include <iso646.h>
            #include <wchar.h>
            #include <wctype.h>
            #endif

            #if __STDC_VERSION__ >= 199901
            #ifndef __STDC_NO_COMPLEX__
            #include <complex.h>
            #endif
            #include <fenv.h>
            #include <inttypes.h>
            #include <stdbool.h>
            #include <stdint.h>
            #include <tgmath.h>
            #endif

            #if __STDC_VERSION__ >= 201112
            #include <stdalign.h>
            #ifndef __STDC_NO_ATOMICS__
            #include <stdatomic.h>
            #endif
            #include <stdnoreturn.h>
            #ifndef __STDC_NO_THREADS__
            #include <threads.h>
            #endif
            #include <uchar.h>
            #endif

            #if __STDC_VERSION__ >= 201710
            /* None added */
            #endif

            #endif /* #if defined __STDC__ && defined __STDC_VERSION__ */

            #endif /* STD_H_ */





            share|improve this answer











            $endgroup$





            • Your code doesn't cover "freestanding implementations" (embedded systems or OS). You could check for #if __STDC_HOSTED__ == 0 and reduce the headers. Freestanding implementations need not provide all headers except a minimal subset, see C11 4/6:




              A conforming freestanding implementation shall accept any strictly conforming program in which the
              use of the features specified in the library clause (clause 7) is confined to the contents of the standard headers <float.h>, <iso646.h>, <limits.h>, <stdalign.h>, <stdarg.h>, <stdbool.h>, <stddef.h>, <stdint.h>, and
              <stdnoreturn.h>




              Though of course freestanding implementations may provide other headers too, making this hard to fulfil without a specific implementation in mind.



            • Style issue: you should indent everything within #if... #endif just as you would for regular if statements. It is also good practice to leave a comment /* */ after each #endif to document which #if is belongs to.



            EDIT: proposed indention fix



            #ifndef STD_H_
            #define STD_H_

            #include <assert.h>
            #include <ctype.h>
            #include <errno.h>
            #include <float.h>
            #include <limits.h>
            #include <locale.h>
            #include <math.h>
            #include <setjmp.h>
            #include <signal.h>
            #include <stdarg.h>
            #include <stddef.h>
            #include <stdio.h>
            #include <stdlib.h>
            #include <string.h>
            #include <time.h>

            #if defined __STDC__ && defined __STDC_VERSION__

            #if __STDC_VERSION__ >= 199409
            #include <iso646.h>
            #include <wchar.h>
            #include <wctype.h>
            #endif

            #if __STDC_VERSION__ >= 199901
            #ifndef __STDC_NO_COMPLEX__
            #include <complex.h>
            #endif
            #include <fenv.h>
            #include <inttypes.h>
            #include <stdbool.h>
            #include <stdint.h>
            #include <tgmath.h>
            #endif

            #if __STDC_VERSION__ >= 201112
            #include <stdalign.h>
            #ifndef __STDC_NO_ATOMICS__
            #include <stdatomic.h>
            #endif
            #include <stdnoreturn.h>
            #ifndef __STDC_NO_THREADS__
            #include <threads.h>
            #endif
            #include <uchar.h>
            #endif

            #if __STDC_VERSION__ >= 201710
            /* None added */
            #endif

            #endif /* #if defined __STDC__ && defined __STDC_VERSION__ */

            #endif /* STD_H_ */






            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited 13 hours ago

























            answered 14 hours ago









            LundinLundin

            1,862823




            1,862823












            • $begingroup$
              Please post a sample # indent. I have tried various styles, ` #if bar` (my auto formatter (Eclipse) keeps shifting them left ) and # if bar which looks odd. Perhaps you have another?
              $endgroup$
              – chux
              14 hours ago










            • $begingroup$
              @chux Posted. After trying some 30+ different, magic IDEs including GNU indent, I'm convinced that mankind will never develop intelligent AI. So I tend to fall back to good ole spacebar :)
              $endgroup$
              – Lundin
              13 hours ago


















            • $begingroup$
              Please post a sample # indent. I have tried various styles, ` #if bar` (my auto formatter (Eclipse) keeps shifting them left ) and # if bar which looks odd. Perhaps you have another?
              $endgroup$
              – chux
              14 hours ago










            • $begingroup$
              @chux Posted. After trying some 30+ different, magic IDEs including GNU indent, I'm convinced that mankind will never develop intelligent AI. So I tend to fall back to good ole spacebar :)
              $endgroup$
              – Lundin
              13 hours ago
















            $begingroup$
            Please post a sample # indent. I have tried various styles, ` #if bar` (my auto formatter (Eclipse) keeps shifting them left ) and # if bar which looks odd. Perhaps you have another?
            $endgroup$
            – chux
            14 hours ago




            $begingroup$
            Please post a sample # indent. I have tried various styles, ` #if bar` (my auto formatter (Eclipse) keeps shifting them left ) and # if bar which looks odd. Perhaps you have another?
            $endgroup$
            – chux
            14 hours ago












            $begingroup$
            @chux Posted. After trying some 30+ different, magic IDEs including GNU indent, I'm convinced that mankind will never develop intelligent AI. So I tend to fall back to good ole spacebar :)
            $endgroup$
            – Lundin
            13 hours ago




            $begingroup$
            @chux Posted. After trying some 30+ different, magic IDEs including GNU indent, I'm convinced that mankind will never develop intelligent AI. So I tend to fall back to good ole spacebar :)
            $endgroup$
            – Lundin
            13 hours ago


















            draft saved

            draft discarded




















































            Thanks for contributing an answer to Code Review Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            Use MathJax to format equations. MathJax reference.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f216119%2fheader-file-that-includes-all-standard-c-library-headers%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            is 'sed' thread safeWhat should someone know about using Python scripts in the shell?Nexenta bash script uses...

            How do i solve the “ No module named 'mlxtend' ” issue on Jupyter?

            Pilgersdorf Inhaltsverzeichnis Geografie | Geschichte | Bevölkerungsentwicklung | Politik | Kultur...