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

## 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 on other sites
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 on other sites
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 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 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 on other sites
Quote:
 Original post by Lord BartHello stroma,you mean you did this#ifndef _MATHHDR_H_#define _MATHHDR_H_#incldue 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 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 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 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?

1. 1
Rutin
31
2. 2
3. 3
4. 4
5. 5

• 13
• 57
• 11
• 10
• 14
• ### Forum Statistics

• Total Topics
632967
• Total Posts
3009557
• ### Who's Online (See full list)

There are no registered users currently online

×