Jump to content
  • Advertisement
Sign in to follow this  
stroma

headers

This topic is 4884 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

hi, i am making a math lib. i write a MathHdr.h file which includes all necessery header files and defines for the lib. and i tried to used it with vector.h file; i type #include "mathhdr.h" but it did not complie because cannot include any of include files in the mathhdr.h, because _MATHHDR_H_ already defined. (i use ifndef and define keywords at the top of the header files) (i used main header because i do not want to include "matrix", "plane".. etc, every time) i see some programs use the same system, bu mine did not worked. should i use procomplied headers? how? pragma hdrstop? any suggestions? thx..

Share this post


Link to post
Share on other sites
Advertisement
Suggestions:

1. Try throwing '#pragma once' in the header
2. You didn't mention it but did you have the ifndef's endif at the end of the header file
3. Clean rebuild.

You should be able to include anything you want anywhere any number of times if you have the inclusion guards set correctly.

Thats all i can think of,

ace

Share this post


Link to post
Share on other sites
thanks for quick answer
1- to main header? i mean mathhdr.h? isnt it the same thing with ifndef x define x "code" endif ? (didnt solve either)
2-of course
3-i always doing that.

what is "inclusion guards"_?

Share this post


Link to post
Share on other sites
Hello stroma,

you mean you did this

#ifndef _MATHHDR_H_
#define _MATHHDR_H_

#incldue <vecotr>
etc

...


#endif /* to end the ifndef _MATHHDR_H_ code*/

you should be able to include this anywere.
You aren't defining _MATHHDR_H_ somewere else are you?

Share this post


Link to post
Share on other sites
visual studio can define the classes, i mean if i move cursor to a class mermber, it says where it defined, but when compling it says undefined for same object. :? isnt that strange?

Share this post


Link to post
Share on other sites
Quote:
Original post by Lord Bart
Hello stroma,

you mean you did this

#ifndef _MATHHDR_H_
#define _MATHHDR_H_

#incldue <vecotr>
etc

...


#endif /* to end the ifndef _MATHHDR_H_ code*/

you should be able to include this anywere.
You aren't defining _MATHHDR_H_ somewere else are you?

yes i use the same. but my files cannot include the include files in mathhdr.
edit: i mean if i say include "mathhdr.h" in one file, that file cannot define the vector classes and says undefined.

Share this post


Link to post
Share on other sites
Is the path to MathHdr.h in the compile line do you see -I with the path were it lives, eats and sleeps.

Lord Bart :)

Share this post


Link to post
Share on other sites
Quote:
Original post by stromai type #include "mathhdr.h" but it did not complie because cannot include any of include files in the mathhdr.h, because _MATHHDR_H_ already defined.


Are you defining _MATHHDR_H_ in each header? It should be unique for one header file. Each header file should have a different name defined.

Share this post


Link to post
Share on other sites
Quote:
Original post by petewood
Quote:
Original post by stromai type #include "mathhdr.h" but it did not complie because cannot include any of include files in the mathhdr.h, because _MATHHDR_H_ already defined.


Are you defining _MATHHDR_H_ in each header? It should be unique for one header file. Each header file should have a different name defined.

there are no "__MATH_MATHHDR_H__" expect :
#ifndef __MATH_MATHHDR_H__
#define __MATH_MATHHDR_H__
...
includes..
...
defines...
...
#endif /* __MATH_MATHHDR_H__ */


what about precomplied headers? what r they for? i have never used them, can it solve this?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!