• ### Announcements

#### Archived

This topic is now archived and is closed to further replies.

# Weird compile errors

## Recommended Posts

##### Share on other sites

  #ifndef _MYHEADER__H_#define _MYHEADER__H_// everything your header would normally have inside#endif // _MYHEADER__H_

Of course, the particular name you use for the "include guard" constant is irrelevant, just as long as its unique throughout your project, which is why most people make it take a form vaguely resembling the particular header's name.

Edited by - merlin9x9 on January 28, 2002 11:35:47 PM

##### Share on other sites

to fix the first 8 linker errrors

on top of tga.h

#ifndef __TGA_H__
#define __TGA_H__

and at the bottom of tga.h

#endif

to fix the last 2

#pragma comment(lib, "glu32.lib")

##### Share on other sites
none of thoes fixed the TGA problems but linking the glu32.lib worked for the last 2

##### Share on other sites
I've tried using include guards but they dont work. They are different for all headers, but if I insert #include "Tga.h" into my main.cpp i get even more of the above errors.
I have #include Tga.h in two different files. One is in TGALoader.cpp. And the other is in bubbles.cpp. bubbles.cpp calls LoadTGA() which loads a targa file. I think the include is necessary in both places.

Arent include guards supposed to keep the header from being included a second time? Or are they just for pretty looks?

Edited by - executor_2k2 on January 28, 2002 12:25:45 AM

##### Share on other sites
No, they actually are supposed to do stuff; they keep your header from being included more than once in each translation unit (vaguely, each source file). Are you positive that you''re making the include guards wrap everything in your headers? The only other thing I can think of is that you''re implementing your functions in your headers, which you should never do, unless they''re template functions or are declared as inline (using inline or __inline, in C++ and C, respectively). Otherwise, it must be done this way:

In myfile.h:
  #ifndef _MYFILE__H_#define _MYFILE__H_extern unsigned char* cTGAcompare(int whatever);...#endif

In myfile.c:
  unsigned char* cTGAcompare(int whatever){ ...}

The extern bit tells the compiler that the actual object (a function, in this case) is somewhere else. And then you do the implementation in a source file (.c or .cpp, depending on whether you''re using C or C++, respectively).

• ## Partner Spotlight

• ### Forum Statistics

• Total Topics
627636
• Total Posts
2978331

• 10
• 12
• 22
• 13
• 33