Thread: Standard for header file naming/capitalization?

  1. #1
    vae victus! skorman00's Avatar
    Join Date
    Nov 2003

    Standard for header file naming/capitalization?

    I recently read that .h is reserved for C standard library headers, and all user headers should have a .H in order to distinguish themselves. Is this actually something that is considered a standard convention?

  2. #2
    Registered User
    Join Date
    Apr 2006
    i dont think so... i have been programming in C for the past few years and have always used a ".h" as a header extension.

    Standard C headers are distinguished from user header files in the way they are incuded in a program

    #include <stdio.h>
    #include "userheader.h"

    Note the "<" and ">" for standard headers and quotes for user headers.

  3. #3
    C / C++
    Join Date
    Jan 2006
    The Netherlands
    If you save your "userheader.h" in the includes directory, you can

    #include <userheader.h>
    Operating Systems:
    - Ubuntu 9.04
    - XP

    Compiler: gcc

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    > If you save your "userheader.h" in the includes directory, you can
    Bad idea - there is no standard for naming header files, so you could lose everything when you next update the compiler.

    For all practical purposes, the system include directories should be regarded as read-only.

    If you have your own header of useful tools, then there is no problem creating your own user include directory, adding that to the compiler search path, and doing
    #include <userheader.h>
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  5. #5
    Registered User
    Join Date
    Mar 2006
    But don't expect that approach to be portable!

    C is a very nice guy; he doesn't really care what you use. You can "#include <>" if you wanted to. That ".H" thing is probably just some misguided suggestion you picked up from somewhere. I have never seen any header files explicitly using that kind of extension.

    Besides, on Windows, ".h" and ".H" pretty much mean the same thing
    #include <stdio.h>
    void J(char*a){int f,i=0,c='1';for(;a[i]!='0';++i)if(i==81){
    /3*3+f/3*9+f%3]==c||a[i%9+f*9]==c||a[i-i%9+f]==c)goto e;a[i]=c;J(a);a[i]
    ='0';e:;}}int main(int c,char**v){int t=0;if(c>1){for(;v[1][
    t];++t);if(t==81){J(v[1]);return 0;}}puts("sudoku [0-9]{81}");return 1;}

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Basic text file encoder
    By Abda92 in forum C Programming
    Replies: 15
    Last Post: 05-22-2007, 01:19 PM
  2. Replies: 3
    Last Post: 03-04-2005, 02:46 PM
  3. Making a LIB file from a DEF file for a DLL
    By JMPACS in forum C++ Programming
    Replies: 0
    Last Post: 08-02-2003, 08:19 PM
  4. System
    By drdroid in forum C++ Programming
    Replies: 3
    Last Post: 06-28-2002, 10:12 PM
  5. me take a look at this: File Encryptor
    By heljy in forum C Programming
    Replies: 3
    Last Post: 03-23-2002, 10:57 AM