Header Files

Started by
2 comments, last by ShadowGlance 21 years, 9 months ago
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"
"I bow to no one and give service only to cause"
Advertisement
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

Richard "Superpig" Fine - saving pigs from untimely fates - Microsoft DirectX MVP 2006/2007/2008/2009
"Shaders are not meant to do everything. Of course you can try to use it for everything, but it's like playing football using cabbage." - MickeyMouse

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

Richard "Superpig" Fine - saving pigs from untimely fates - Microsoft DirectX MVP 2006/2007/2008/2009
"Shaders are not meant to do everything. Of course you can try to use it for everything, but it's like playing football using cabbage." - MickeyMouse

This topic is closed to new replies.

Advertisement