0

Have two files:

CIoHandler.h

#pragma once
#include "CSession.h"
class CIoHandler
{
    public:
        CIoHandler();
        ~CIoHandler();
        void AuthenticateUser();
        void ConvertUnicodeToAscii();
        void DoNTLMAuth();
        void GetAndSetSocket();
        void GetElevatedToken();
        void GetHeaderMessage();
        void GetUserNameW();
        void HandleOperatorMessage();
        void Init(CSession *cSession);
        void IsLocalAccount();
        int IsLoopBack();
        void IsSPNFQDNName();
        int IsSPNLocalInterface();
        void IsSPNPresentInRegistry();
        void IsTimedOut();
        void IssueReadFromSocket();
        void OnDataFromSocket();
        void OnReadFromPipeCompletion();
        void ParseAndValidateAccount();
        void ProcessAuthenticationLine();
        void ProcessCommandLine();
        void ProcessDataFromSocket();
        void ReadRegistryKey();
        void SendDetailsAndAskForLicense();
        void SendMessageToClient();
        void SendTerminateString();
        void SetPrivilege();
        void WriteMessageToClientDirectly();
        void WriteToClient();
        void WriteToServer();
    

    void WriteToSocket();

};

CSession.h

#pragma once

#include "CIoHandler.h"

class CSession
{
    private:
        CIoHandler* _CIoHandler;

    public:     
        CSession();
        ~CSession();
        void CollectPeerInfo();
        void FreeInitialVariables();
        void GetRegistryValues();
        void Init();
        void IsAnAdministratorOrMember();
        void SecpSetIPandPort();
        void Shutdown();
        void WaitForIO();
};

When compiling with Visual Studio 2019 get the following errors:

CSession.h(8,13): error C2143: syntax error: missing ';' before '*'
CSession.h(8,13): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
CSession.h(8,26): error C2238: unexpected token(s) preceding ';'
CIoHandler.h(16,22): error C2061: syntax error: identifier 'CSession'
CIoHandler.h(16,22): error C2061: syntax error: identifier 'CSession'

Removing

#include "CIoHandler.h"
private:
            CIoHandler* _CIoHandler;

From CSession.h it compiles What do I need to so I can use CIoHandler in CSession class definition

Malcolm McCaffery
  • 2,468
  • 1
  • 22
  • 43
  • Look at your headers, the first includes the second which includes the first again. – john Aug 12 '20 at 08:10

1 Answers1

1

You have a cyclic include dependency. To break the cycle replace

#include "CIoHandler.h"

with a forward declaration.

class CIoHandler;
john
  • 85,011
  • 4
  • 57
  • 81