By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,795 Members | 1,832 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,795 IT Pros & Developers. It's quick & easy.

Using C++ header files in C application

P: 3
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.
Mar 15 '07 #1
Share this Question
Share on Google+
4 Replies


stealwings
P: 34
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.
Mar 15 '07 #2

dmjpro
100+
P: 2,476
check out the hh file content then include in ur code .....

best of luck...
Mar 15 '07 #3

Banfa
Expert Mod 5K+
P: 8,916
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.

... 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"
Mar 15 '07 #4

stealwings
P: 34
IC, thx for your explanation Banfa. I now get to know a little bit more than b4.
Mar 21 '07 #5

Post your reply

Sign in to post your reply or Sign up for a free account.