c++ - Can't use declared structure in another declaration -



c++ - Can't use declared structure in another declaration -

i have header contains class declaration.

dialogexinput.h

#include "stdafx.h" #pragma 1 time #include "utils.h" // cdialogexinput dialog class cdialogexinput : public cdialogex { declare_dynamic(cdialogexinput) public: cstring timeremainedsecstr; cstring caption; int timeoutsec; int mindatasize; int maxdatasize; cstring text; int timeremainedsec; void assignparams (dialogoptions* dop); cdialogexinput(uint nidtemplate, cwnd *pparent = null); afx_msg void ontimer(uint utime); virtual ~cdialogexinput(); void setontop(); protected: virtual void dodataexchange(cdataexchange* pdx); // ddx/ddv back upwards virtual bool oninitdialog(); declare_message_map() };

compiler can't find dialogoptions, declared in utils.h. , dialogexinput.h includes utils.h.

error 1 error c2061: syntax error : identifier 'dialogoptions'

utils.h

#ifndef utils_h #define utils_h #include "inputdialog.h" #include <string> using namespace std; #define currency_eur 978 extern hwnd authmsghwnd; struct dialogoptions { cstring caption ; cstring defaulttext; int maxtimeoutexpected; int maxchars; int minchars; int modalresult; int inputtimeremained; } ; void errorexit(); const wchar_t *getwc(const char *c); bool getproductandversion(cstringa & strproductname, cstringa & strproductversion); void doinputdialog(dialogoptions *pdo, string & answer); void doyesnodialog(dialogoptions *pdo, string & reply ); wstring termtowchar (const char* value); string gettime(string format = "%d-%m-%y %i:%m:%s" ); #endif utils_h

so problem? why dialogexinput.h don't see dialogoptions

a circular include exists

dialogexinput.h

#pragma 1 time #include "utils.h"

inputdialog.h

#include "dialogexinput.h"

utils.h

#include "inputdialog.h"

so if include inputdialog.h before of others (where goes wrong) files read in next order

inputdialog.h dialogexinput.h utils.h

and dialogexinput can hence not see content of utils.h.

if add together forwards declaration of struct dialogoptions @ the start of dialogexinput .h

#include "stdafx.h" #pragma 1 time #include "utils.h" struct dialogoptions; // forwards declare utilize pointer/reference it. // cdialogexinput dialog class cdialogexinput : public cdialogex

making separate include file option.

also should break circular include, checking if need includes. if don't , bite later.

c++ visual-c++

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -