On Tue, 25 Mar 2003 10:45:05 -0500 "Steven T. Hatton" <hattons@globalsymmetry.com> wrote:
I want to use the class described on the page found here on my SuSE 8.1. (It requiers the CommonC++ documentation to be installed.) file:///usr/share/doc/packages/CommonC++-doc/html/classost_1_1_string _tokenizer.html#_details
How would one typically (correctly) include such a library in his code? If I follow K&R 2nd. Ed., they put the #includes for libraries in any .c file that relies on them. Is that technically necessarily? From my experimentation, id doesn't /seem/ to be necessary. All that is required to get the code to run is that the one of the header files referenced in the .c includes the particular library.
I think you are mixing C and C++. K&R 2nd Ed. is ANSI 89 C, not c++. In general, most header files are set up with some protection from multiple inclusions as John Lamb mentioned. Also, in a properly written environment, header files should be self referencing, such that if you need some definition that is referenced by a header file and not directly by your C or C++ code, that header file should include the header files it depends on. Generally, header files include function prototypes, structure definitions, class definitions, et. al. If you have a c or c++ module, you only need to include those header files needed by that module. Libraries are different. Those are referenced at link time by the -l (lower case L) option. It is not a requirement in C that you prototype a function before it is used. But, C++ does require that. My rule of thumb is to include only what my module requires. But, others like to include everything that other modules in the project require. -- -- Gerald Feldman <gfeldman@attbi.com> Boston Computer Solutions and Consulting ICQ#156300 PGP key id:C5061EA9 PGP Key fingerprint:053C 73EC 3AC1 5C44 3E14 9245 FB00 3ED5 C506 1EA9