Re: one header file defines a struct and the other uses it.
What is correct linkage method?
Where are your include guards for that header? That is a compiler error, and the reason is more than likely that you do not have include guards to prevent the definition being encountered two (or more times) per compilation unit.
Re: one header file defines a struct and the other uses it.
Originally Posted by lucky6969b
Sorry, I have solved it myself
That is no solution. All you're doing is delaying the inevitable, and that is two or more inclusions of the header file in a single compilation unit.
The actual solution is to use include guards, as cilu and myself have pointed out. With a more complex program, you would go crazy trying to figure out what header goes first, second, third, etc. without include guards. You may not even have a scenario where you can guarantee that the header is seen only once by the compiler, so how are you going to solve that issue without using include guards?
Re: one header file defines a struct and the other uses it.
You don't have include guards in your header, which means each symbol defined there will be created once in each translation unit (cpp file) that includes the header. You need either this:
Code:
#pragma once
struct D3DXMESHCONTAINER_DERIVED
{
};
or
Code:
#ifndef _THEHEADER_
#define _THEHEADER_
struct D3DXMESHCONTAINER_DERIVED
{
};
#endif // end of header
Bookmarks