Sign in to follow this  

vc6++ and .h .cpp .lib

This topic is 4684 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

in vc6++ you have .h files and .cpp files to include into your project. the .h are simple headings and .cpp the actual source code. then you have .lib files isnt a .lib file a library of functions,classes or a bunch of .h and .cpp files compiled into a .dll in directX you need to inlude .h /.cpp and .lib for directX to work...why so much? why not just 1 or the other also in the directX code you have it seems it is c++ ....the microsoft way. functions need to be passes & and some simply pointers.....not like normal function calls in c++. there also also variables which are structures which are also pointers......why there are variable type in vc++ win32 apps i have never seen before...DWORD,TCHAR..why? i understand simple c++ but the 3rd party c++ add ons and includes dont make sense other than do it that way and it works. i can get it to work but i dont understand the reasons why it has to be done that way...

Share this post


Link to post
Share on other sites
look at create new project and look for static libraries

those are your .lib files

you need the headers and the .lib file to reuse them in your code

QUOTE:
functions need to be passes & and some simply pointers.....not like normal function calls in c++. there also also variables which are structures which are also pointers......why


what exactly do you mean?

struc blah {
asdadasd
}*pblah;

pblah is a pointer in this case

typedef struct blah {
}*pblah ;

pblah is a custom type

pblah s;

s is a pointer to a struct blah

s = new blah;


sometimes you will see classes or structures passed to functions with lots of function pointers

void (* dosomething)();

void blahfunc(){};
dosomething = blahfunc;

dosomething();

those are often used to give dlls access to api calls but i doubt you will need this very often

they are also used for callback functions by physique engines ^^

feel free to mail me if you got some questions


P.S.: if theres a critical mistake in my post please correct me

Share this post


Link to post
Share on other sites
Often when you are using 3rd party libraries, such as the Win32 API, you will see user-defined (custom) types. For example, if I distributed a library with the following class in it:

class CFoo {
int x;

public:
CFoo() { x = 0; }
~CFoo() {}
int GetX() const { return x; }
void SetX(int val) { x = val; }
};



People using my library would then be able to create new instances of CFoo and use the member functions GetX() and SetX() like this:


//....
CFoo Bar;
int n = 10;
Bar.SetX(n);
int x = Bar.GetX();
//....


Anyway to make a long story short (You're probably asleep already...), custom types help users interact with the libraries they are using. As far as .cpp, .h, and .lib files - they help keep your code modular. It would be very messy if you dumped all of the Win32 API plus your code into one .cpp file, wouldn't it? ;)

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Quote:
Original post by Sure Shot
Often when you are using 3rd party libraries, such as the Win32 API, you will see user-defined (custom) types. For example, if I distributed a library with the following class in it:

class CFoo {
int x;

public:
CFoo() { x = 0; }
~CFoo() {}
int GetX() const { return x; }
void SetX(int val) { x = val; }
};



People using my library would then be able to create new instances of CFoo and use the member functions GetX() and SetX() like this:


//....
CFoo Bar;
int n = 10;
Bar.SetX(n);
int x = Bar.GetX();
//....


Anyway to make a long story short (You're probably asleep already...), custom types help users interact with the libraries they are using. As far as .cpp, .h, and .lib files - they help keep your code modular. It would be very messy if you dumped all of the Win32 API plus your code into one .cpp file, wouldn't it? ;)


hi
with directX libs, thats not what you get, you have to make functions calls with &....I know you pass by reference but you dont do it in the call. As well as structure pointers variables, you dont get many Classes (if any)defined so baically as above either. varibale type used are TCHAR,DWORD which are not hard to use but why do you need to do it this way

Share this post


Link to post
Share on other sites
Yes, DirectX does use many complex structures unlike the class I just posted. But, in principle, they behave the same way, only on a different scale. About TCHARs and DWORDs, they are simply custom types that have been typedef'ed in the API. For example, TCHAR is typedef'ed like this:

typedef char TCHAR;

So, you could pass a char when you are asked to pass a TCHAR, but it's generally better to just go with their typedef. I hope this answers any questions...

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Quote:
Original post by Sure Shot
Yes, DirectX does use many complex structures unlike the class I just posted. But, in principle, they behave the same way, only on a different scale. About TCHARs and DWORDs, they are simply custom types that have been typedef'ed in the API. For example, TCHAR is typedef'ed like this:

typedef char TCHAR;

So, you could pass a char when you are asked to pass a TCHAR, but it's generally better to just go with their typedef. I hope this answers any questions...




interesting that they use char as a typedef. As I said before i can get directXt to work but i dont really understand it too well unlike regular c++.

How about passing & for a call rather than a function header and structure typedef as a pointer

thanks for the reply

Share this post


Link to post
Share on other sites
Quote:
Original post by jagguy
i understand simple c++ but the 3rd party c++ add ons and includes dont make sense other than do it that way and it works. i can get it to work but i dont understand the reasons why it has to be done that way...


Have you ever tried useing OpenGL with something like SDL? You don't have nearly so many annoying and weird types, its much easier to get your head around and you loose almost nothing in functionality (the only thing you can't do is the cutting/bleeding edge extensions that DX impliments befor they're put into the OpenGL standard but if your just starting out thats won't be an issue for a few years anyway). I can't stand MS's way of doing things - all the types with capital letters that arn't constants etc are really quite annoying and make the code look really ugly IMHO. OpenGL does have some of its own types too but they are quite simple to understand and you don't need to use them (GLint is clearly an int for example). Just remember there are alternatives to DirectX.

I believe that typedefs are so they can change things on different systems. Its so you can always garentee your ints are 4 bytes, because on different systems you can typedef your custom type to different local types. As for some of the other weird and wonderfull stucts/classes quite a bit of it is for backwards compatability (really pisses people off when they can't use their old code). So whenever MS tries to make something better they have to make sure the old way still works. Also its a style choice. Thats the way windows code works, so thats they way they'll keep writing it. I personally don't like it, but I'm sure there are others who do ... personal preference.

Share this post


Link to post
Share on other sites

This topic is 4684 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this