Header Files
How do I create function librarys? Is there some sort of special syntax I need to be using?
thanks
"I bow to no one and give service only to cause"
It''s all about how you compile and link it.
Really, it depends on the build system you''re using.
For Microsoft Visual C++, when creating a new project choose ''Static Library.'' Add your functions as normal (remember that libraries don''t need main(), WinMain(), or DLLMain(), or any variation of same). Build. You should have a library.
Superpig
- saving pigs from untimely fates
- sleeps in a ham-mock at www.thebinaryrefinery.cjb.net
Really, it depends on the build system you''re using.
For Microsoft Visual C++, when creating a new project choose ''Static Library.'' Add your functions as normal (remember that libraries don''t need main(), WinMain(), or DLLMain(), or any variation of same). Build. You should have a library.
Superpig
- saving pigs from untimely fates
- sleeps in a ham-mock at www.thebinaryrefinery.cjb.net
Basically all you will have to do to create a function library is just create the code in normal C++ in one file and name it something like mylibrary .h . This is because The preprocessor will substitute all of that code in when you say, for example, #include "somelibrary.h" <- notice that there are quotes around the library, that just means that it is in the same directory as the C++ file. if it isn''t and is within subdirectories of it you could just include those directories in the file name.
quote:Original post by pointer0death
Basically all you will have to do to create a function library is just create the code in normal C++ in one file and name it something like mylibrary .h . This is because The preprocessor will substitute all of that code in when you say, for example, #include "somelibrary.h" <- notice that there are quotes around the library, that just means that it is in the same directory as the C++ file. if it isn''t and is within subdirectories of it you could just include those directories in the file name.
I think you''re a little confused. The code within the library - when you''re building it - is irrelevant.
What you''re describing sounds more like when you want to *use* the library. You need to use the same header files in the code using the library as you did when you made the library - so that the structures are the same layout, and so that the functions have correct return types and arguments.
Superpig
- saving pigs from untimely fates
- sleeps in a ham-mock at www.thebinaryrefinery.cjb.net
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement