different basic types

I need to explain why I got this error

makewindows.h(44): error C2371: 'PAGES_TEMPLATES_BACKUP' : redefinition; different basic types
1> i:\pc improve\c++ visual studio ide\source codes\aokts-1.0.1 r72 update_test\view\makewindows.h(43) : see declaration of 'PAGES_TEMPLATES_BACKUP'

1
2
3
4
5
6
7
8
typedef struct PAGES_TEMPLATES_BACKUP_s
{
PROPSHEETPAGE Units1;
PROPSHEETPAGE Triggers1;
PROPSHEETPAGE Units2;
PROPSHEETPAGE Triggers2;
} PAGES_TEMPLATES_BACKUP;
extern struct PAGES_TEMPLATES_BACKUP pagesBackup;


I just want to create new instance pagesBackup of type PAGES_TEMPLATES_BACKUP and the instance must be extern.

and how can I display the Output (errors) in Visual Studio 2010?

If I type
 
extern PAGES_TEMPLATES_BACKUP pagesBackup;

so I got error
makewindows.cpp(53): error C2679: binary '=' : no operator found which takes a right-hand operand of type 'LPCSTR' (or there is no acceptable conversion)
1> c:\program files\microsoft sdks\windows\v7.0a\include\prsht.h(208): could be '_PROPSHEETPAGEA &_PROPSHEETPAGEA::operator =(const _PROPSHEETPAGEA &)'
1> while trying to match the argument list '(PROPSHEETPAGEA, LPCSTR)'
when I try to use it:

 
pagesBackup.Units1 = pg.pszTemplate;

Last edited on
http://www.eelis.net/iso-c++/testcase.xhtml
Make sure your testcase is self-contained and actually reproduces the problem

A testcase is said to reproduce the problem if, when we independently try to compile and run the testcase locally, we get the same compiler error (or our compiler's version of it) or erroneous program output specified in the testcase. A testcase that does not reproduce the problem is useless. (...)

A testcase consisting of randomly copy&paste'd bits of code that you thought were relevant can obviously not reproduce the problem.



> PAGES_TEMPLATES_BACKUP' : redefinition
you have defined the struct several times.
perhaps you've included the file twice and didn't use include guards.


> and the instance must be extern.
¿are you sure?


> If I type
> extern PAGES_TEMPLATES_BACKUP pagesBackup;
yes, that's what you have to type (that's what the typedef do).


> so I got error
> binary '=' : no operator found which takes a right-hand operand of type 'LPCSTR'
> pagesBackup.Units1 = pg.pszTemplate;
that's referring to another line.
¿what's `pg'?
¿what's PROPSHEETPAGE?
¿how do you expect to assign it an string literal?
I am giving here complete file:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#include "makewindows.h"

#include "editorsDlgProc.h"
DLGPROC procs[NUM_PAGES] =
{
	&IMsgsDlgProc,
	&PlyDlgProc,
	&VictDlgProc,
	&DisDlgProc,
	&MapDlgProc,
	&UnitDlgProc,
	&TrigDlgProc,
	&Units2DlgProc,
	&Triggers2DlgProc
};

HWND MakeMapView(HWND sheet, int cmdshow)
{
	HWND ret;
	RECT rect;

	GetWindowRect(sheet, &rect);
	ret = CreateMapView(sheet, rect.right + MAP_OFFSET, rect.top, &scen);
	ShowWindow(ret, cmdshow);

	return ret;
}

/*
	MakeSheet: Creates the main property sheet window.

	Parameters:
	HINSTANCE app: Handle to the application loading the sheet.

	Note: Called once and only once by WinMain().
*/
HWND MakeSheet(HINSTANCE app)
{
	PROPSHEETHEADER header;
	HPROPSHEETPAGE pages[NUM_PAGES];
	PROPSHEETPAGE pg;	//used to create each page
	HWND sheet;

	//create pages

	pg.dwSize = sizeof(PROPSHEETPAGE);
	pg.dwFlags = PSP_DEFAULT;
	pg.hInstance = app;

	for (int i = 0; i < NUM_PAGES; i++)
	{
		pg.pszTemplate = MAKEINTRESOURCE(IDD_MSGS + i);	//template IDs are in display order
		/*
		switch (i){
			case 5: // Units
				pagesBackup.Units1 = pg.pszTemplate;
				break;
			case 6: // Triggers
				pagesBackup.Triggers1 = pg.pszTemplate;
				break;
			case 7: // Units 2
				pagesBackup.Units2 = pg.pszTemplate;
				break;
			case 8: // Triggers 2
				pagesBackup.Triggers2 = pg.pszTemplate;
				break;
		}
		*/
		pg.pfnDlgProc = procs[i];
		pg.lParam = 0;
		pages[i] = CreatePropertySheetPage(&pg);
	}

	//create sheet

	header.dwSize = sizeof(header);
	header.dwFlags = PSH_MODELESS | PSH_USECALLBACK |
		PSH_NOAPPLYNOW | PSH_NOCONTEXTHELP | PSH_USEICONID;
	header.hwndParent = NULL;
	header.hInstance = app;
	header.pszIcon = MAKEINTRESOURCE(IDI_LOGO);
	header.pszCaption = szTitle;
	header.nPages = NUM_PAGES;
	header.nStartPage = 0;
	header.phpage = pages;

	header.pfnCallback = &PropSheetProc;

	sheet = (HWND)PropertySheet(&header);
	
	/* Remove Units and Triggers Page
	   until the Scenario is loaded;
	   The Units 2 and Triggers 2 Pages will be there
	   */
	PropSheet_RemovePage( sheet, 5, pages[5] );
	PropSheet_RemovePage( sheet, 6, pages[6] );

	//add status bar here (can't be done in PropertySheetProc)
	propdata.statusbar = CreateWindow(STATUSCLASSNAME, welcome,
		WS_CHILD | WS_VISIBLE, 0, 0, 0, 0,
		sheet, (HMENU)IDS_MAIN, aokts, NULL);

	return sheet;
}

// HINSTANCE app: Handle to the application using the sheet
HWND SwitchPages(HINSTANCE app, HWND hPropSheetDlg, scenario * scenario )
{
    PropSheet_RemovePage( sheet, 5, pages[5] );
    PropSheet_RemovePage( sheet, 6, pages[6] );
	if ( scenario.isOpen() )
	 {
	PropSheet_InsertPage( HWND hPropSheetDlg, 5, hpage);
	PropSheet_InsertPage( HWND hPropSheetDlg, 6, hpage);
	);
	 }
	else
	{
	PropSheet_InsertPage( HWND hPropSheetDlg, 7, hpage);
	PropSheet_InsertPage( HWND hPropSheetDlg, 8, hpage);
	}

}


On the sheet there are these Tabs:
[Info],[Player],[Victory],[Disables],[Map],[Units],[Triggers]
There are two modules for Units and Triggers (Units1, Triggers1, Users2, Trigger2). When I create main Window with sheet, so Unit1 and Triggers1 must be loaded. But when I open file, then Units1 and Triggers1 is removed and Units2 and Trigger2 should be inserted instead them. If I close file, so I want to remove Units2 and Trigger2 and inset Units1 and Triggers2.

The macro PropSheet_InsertPage expects handle to the page, so I need create struct in which I will save those 4 pages handles while pages been created.
Last edited on
1
2
3
//PROPSHEETPAGE Units1;
PROPSHEETPAGE pg;
pagesBackup.Units1 = pg.pszTemplate; //¿what do you expect this to do? 

Given that both `Units`' and `pg' are pages, I would have expected pagesBackup.Units1 = pg;

¿how do you intent to create a page with an string?


PropSheet_InsertPage( HWND /* ¿what's that doing here? */ hPropSheetDlg, 7, hpage);


> I am giving here complete file:
You are giving one file of your project.
Again, self-contained
Here is header:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#ifndef AOKTS_DIALOGWIN_H
#define AOKTS_DIALOGWIN_H

#include "../model/scen.h"
#include "mapview.h"
#include "../resource.h" // must be included after Windows stuff
#include "strings.h"


#include <commdlg.h>
#define WIN32_LEAN_AND_MEAN

#include <windows.h>
#include <CommCtrl.h>
#include "propsheetproc.h"
//Number of property pages (tabs)
#define NUM_PAGES 9

#define MAP_OFFSET 10

// data shared by the property pages:

extern class Scenario scen;
extern HINSTANCE aokts;

extern struct PropSheetData
{
	int pindex;			//current player number
	class Player *p;			//current player struct
	int sel0, sel1;	//page dependant, should be reset on SETACTIVE
	HWND statusbar;
	HWND mapview;
	HMENU menu;
	UINT tformat, ecformat, mcformat;	//clipboard formats
} propdata;

typedef struct PAGES_TEMPLATES_BACKUP_s
{
PROPSHEETPAGE Units1;
PROPSHEETPAGE Triggers1;
PROPSHEETPAGE Units2;
PROPSHEETPAGE Triggers2;
} PAGES_TEMPLATES_BACKUP;
struct PAGES_TEMPLATES_BACKUP pagesBackup;


HWND MakeMapView(HWND sheet, int cmdshow);

/*
	MakeSheet: Creates the main property sheet window.

	Parameters:
	HINSTANCE app: Handle to the application loading the sheet.

	Note: Called once and only once by WinMain().
*/
HWND MakeSheet(HINSTANCE app);


#endif	// AOKTS_DIALOGWIN_H 


I think the extern is not needed, but I still have strange error there:

'PAGES_TEMPLATES_BACKUP' : redefinition; different basic types
view\makewindows.h(43) : see declaration of 'PAGES_TEMPLATES_BACKUP'
view\makewindows.h(44): error C2079: 'pagesBackup' uses undefined struct 'PAGES_TEMPLATES_BACKUP'

If I remove typedef:
still:
pagesBackup' uses undefined struct 'PAGES_TEMPLATES_BACKUP'

I need to remove the error first to continue.

Yet I tried to remove the word "struct" when I am trying to create new instance and here is new error:
error C2146: syntax error : missing ';' before identifier 'pagesBackup'

error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
error C2371: 'PAGES_TEMPLATES_BACKUP' : redefinition; different basic types
see declaration of 'PAGES_TEMPLATES_BACKUP'

PAGES_TEMPLATES_BACKUP pagesBackup;

Edit:
The MakeSheet function could look like this:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
HWND MakeSheet(HINSTANCE app)
{
	PROPSHEETHEADER header;
	HPROPSHEETPAGE pages[NUM_PAGES];
	PROPSHEETPAGE pg;	//used to create each page
	HWND sheet;

	//create pages

	pg.dwSize = sizeof(PROPSHEETPAGE);
	pg.dwFlags = PSP_DEFAULT;
	pg.hInstance = app;
	
	pagesBackup.Units1.dwSize = 
	pagesBackup.Units2.dwSize = 
	pagesBackup.Triggers1.dwSize = 
	pagesBackup.Triggers2.dwSize =
			pg.dwSize;
	pagesBackup.Units1.hInstance = 
	pagesBackup.Units2.hInstance = 
	pagesBackup.Triggers1.hInstance = 
	pagesBackup.Triggers2.hInstance =
			pg.hInstance;
	pagesBackup.Units1.dwFlags = 
	pagesBackup.Units2.dwFlags = 
	pagesBackup.Triggers1.dwFlags = 
	pagesBackup.Triggers2.dwFlags =
			pg.dwFlags;
	
		for (int i = 0; i < NUM_PAGES; i++)
			{
			pg.pszTemplate = MAKEINTRESOURCE(IDD_MSGS + i);	//template IDs are in display order
			if (i>4)
				{
				switch (i){
					case 5: // Units
						pagesBackup.Units1.pszTemplate = pg.pszTemplate;
						break;
					case 6: // Triggers
						pagesBackup.Triggers1.pszTemplate = pg.pszTemplate;
						break;
					case 7: // Units 2
						pagesBackup.Units2.pszTemplate = pg.pszTemplate;
						break;
					case 8: // Triggers 2
						pagesBackup.Triggers2.pszTemplate = pg.pszTemplate;
						break;
				 } // switch
				} // if
			pg.pfnDlgProc = procs[i];
			pg.lParam = 0;
			pages[i] = CreatePropertySheetPage(&pg);
			} // for

	//create sheet

	header.dwSize = sizeof(header);
	header.dwFlags = PSH_MODELESS | PSH_USECALLBACK |
		PSH_NOAPPLYNOW | PSH_NOCONTEXTHELP | PSH_USEICONID;
	header.hwndParent = NULL;
	header.hInstance = app;
	header.pszIcon = MAKEINTRESOURCE(IDI_LOGO);
	header.pszCaption = szTitle;
	header.nPages = NUM_PAGES;
	header.nStartPage = 0;
	header.phpage = pages;

	header.pfnCallback = &PropSheetProc;

	sheet = (HWND)PropertySheet(&header);
	
	/* Remove Units and Triggers Page
	   until the Scenario is loaded;
	   The Units 2 and Triggers 2 Pages will be there
	   */
	PropSheet_RemovePage( sheet, 5, pages[5] );
	PropSheet_RemovePage( sheet, 6, pages[6] );

	//add status bar here (can't be done in PropertySheetProc)
	propdata.statusbar = CreateWindow(STATUSCLASSNAME, welcome,
		WS_CHILD | WS_VISIBLE, 0, 0, 0, 0,
		sheet, (HMENU)IDS_MAIN, aokts, NULL);

	return sheet;
}


Looks correct in cpp:
PAGES_TEMPLATES_BACKUP pagesBackup;
Last edited on
Looks correct in cpp:
Yes, but not in the header. Without extern you define the variable in the header. So you have multiple definitions (depends on how oftern you include the header of course)
Topic archived. No new replies allowed.