Using C++ header files in C application

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • chinnapandu2004
    New Member
    • Mar 2007
    • 3

    Using C++ header files in C application

    hi, here i am a dought that i found a C++ Project in which they included "constants. hh" i want to include the "constants. hh" file in C, can i directly include the header file or any modifications i hav to do. pls suggest m a idea. if possible to use directly or any conversions give me details.
  • stealwings
    New Member
    • Feb 2007
    • 34

    #2
    Originally posted by chinnapandu2004
    hi, here i am a dought that i found a C++ Project in which they included "constants. hh" i want to include the "constants. hh" file in C, can i directly include the header file or any modifications i hav to do. pls suggest m a idea. if possible to use directly or any conversions give me details.
    Ehmmmm, shouldn't the headers of c++ be like "header.h"? And I think that you will have to do a lot of modifications in that header to include it to your c program since C++ is more advanced than C, in other words C++ can compile C files, but it may not work in vice versa.

    Comment

    • dmjpro
      Top Contributor
      • Jan 2007
      • 2476

      #3
      check out the hh file content then include in ur code .....

      best of luck...

      Comment

      • Banfa
        Recognized Expert Expert
        • Feb 2006
        • 9067

        #4
        Originally posted by stealwings
        Ehmmmm, shouldn't the headers of c++ be like "header.h"?
        That is only convention, C / C++ are not fussy and will normally include any old file you care to name. Perhaps the project the file came from uses .hh to denote a header file with a specific type of contents. I know I often use .cxx and .hxx when creating template classes.

        Originally posted by stealwings
        ... C++ can compile C files ...
        Not quite true, it is possible to construct C that is not compilable with C++ and without using any really obscure constructions too. For instance the difference in the way they handle void * can be a stumbling block.

        Correctly "C++ can compile most C files with little or no modification"

        Comment

        • stealwings
          New Member
          • Feb 2007
          • 34

          #5
          IC, thx for your explanation Banfa. I now get to know a little bit more than b4.

          Comment

          Working...