If I declare this struct
in my CDialog
header:
struct S_MWB_AUTO_ASSIGN_SETTING
{
bool bIncludeReferencedWeeks{};
bool bAvoidConflicts{};
MSAToolsLibrary::AssignmentType eAssignType;
CString strStartingName;
void (CChristianLifeMinistryEntry::* pfnSetAssignName)(CString);
};
Then, I can use it in the dialog functions. Example:
std::vector<S_MWB_AUTO_ASSIGN_SETTING> vecAutoAssignSettings =
{
{true, true, MSAToolsLibrary::AssignmentType_Host, L"Name 1", &CChristianLifeMinistryEntry::SetVideoHost },
{true, true, MSAToolsLibrary::AssignmentType_CoHost, L"Name 2", &CChristianLifeMinistryEntry::SetVideoCohost },
};
This compiles and builds fine. Now, I tried to move my struct
definition into another header file. Snippet:
namespace CChristianLifeMinistryDefines
{
struct S_MWB_AUTO_ASSIGN_SETTING
{
bool bIncludeReferencedWeeks{};
bool bAvoidConflicts{};
MSAToolsLibrary::AssignmentType eAssignType;
CString strStartingName;
void (CChristianLifeMinistryEntry::* pfnSetAssignName)(CString);
};
}
Now it will not compile:
error C2653: 'MSAToolsLibrary': is not a class or namespace name
error C3646: 'eAssignType': unknown override specifier
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
The MSAToolsLibrary
namespace is created automatically by a TLH file. The problem is that the wrapper class that uses the TLH file also references the same header I am trying to add the struct
too:
#pragma once
#include "ChristianLifeMinistryDefines.h"
#include <map>
#include <vector>
#ifdef _WIN64
#import "..\\..\\MSAToolsLibrary\\MSAToolsLibrary\\bin\\x64\\Release\\MSAToolsLibrary.tlb" raw_interfaces_only named_guids
#else
#import "..\\..\\MSAToolsLibrary\\MSAToolsLibrary\\bin\\x86\\Release\\MSAToolsLibrary.tlb" raw_interfaces_only named_guids
#endif
using namespace CChristianLifeMinistryDefines;
I tried to #include
the TLH wrapper header. No joy.
At the moment I have kept the struct
in the CDialog
header.
I understand about forward declaring structures etc. This feels like a circular reference issue but I cant establish how to forward declare the namespace that is built by the TLH import.