error C2552: 'MyConfigVariables' : non-aggregates cannot be initialized with initializer list

Hi all, i am trying to run one code on Visual studio .NET 2003. And it's givin following error.

error C2552: 'MyConfigVariables' : non-aggregates cannot be initialized with initializer list


here is the code

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
static const SConfigVariable MyConfigVariables[] = {
  CONFIG_STRING(CONFIG_PREV_FILE_0, "File0", NULL),
  CONFIG_STRING(CONFIG_PREV_FILE_1, "File1", NULL),
  CONFIG_STRING(CONFIG_PREV_FILE_2, "File2", NULL),
  CONFIG_STRING(CONFIG_PREV_FILE_3, "File3", NULL),
  CONFIG_BOOL_HELP(CONFIG_LOOPED, "Looped", false, "Replay video"),
  CONFIG_INT_HELP(CONFIG_VOLUME, "Volume", 75, "Set Volume (0 - 100)"),
  CONFIG_BOOL_HELP(CONFIG_MUTED, "AudioMuted", false, "Mute Volume"),
  CONFIG_INT(CONFIG_HTTP_DEBUG, "HttpDebug", LOG_ALERT),
  CONFIG_INT(CONFIG_RTSP_DEBUG, "RtspDebug", LOG_ALERT),
  CONFIG_INT(CONFIG_SDP_DEBUG, "SdpDebug", LOG_ALERT),
  CONFIG_INT_HELP(CONFIG_IPPORT_MIN, "RtpIpPortMin", UINT32_MAX, "Set minimum IP port to receive on"),
  CONFIG_INT_HELP(CONFIG_IPPORT_MAX, "RtpIpPortMax", UINT32_MAX, "Set maximum IP port to receive on"),
  CONFIG_INT(CONFIG_USE_OLD_MP4_LIB, "UseOldMp4Lib", 0),
  CONFIG_INT_HELP(CONFIG_USE_RTP_OVER_RTSP, "UseRtpOverRtsp", 0, "Use RTP in TCP session (for firewalls)"),
  CONFIG_INT(CONFIG_SEND_RTCP_IN_RTP_OVER_RTSP, "SendRtcpInRtpOverRtsp", 0), 
  CONFIG_STRING(CONFIG_PREV_DIRECTORY, "PrevDirectory", NULL),
  CONFIG_INT(CONFIG_RTP_DEBUG, "RtpDebug", LOG_ALERT),
  CONFIG_INT(CONFIG_PLAY_AUDIO, "PlayAudio", 1),
  CONFIG_INT(CONFIG_PLAY_VIDEO, "PlayVideo", 1),
  CONFIG_INT(CONFIG_PLAY_TEXT, "PlayText", 1),
  CONFIG_INT(CONFIG_RTP_BUFFER_TIME_MSEC, "RtpBufferTimeMsec", 2000),
  CONFIG_INT_HELP(CONFIG_MPEG2T_PAM_WAIT_SECS, "Mpeg2tPamWaitSecs", 30, "Time to wait for Program Map (seconds)"),
  CONFIG_INT(CONFIG_LIMIT_AUDIO_SDL_BUFFER, "LimitAudioSdlBuffer", 0),
  CONFIG_INT(CONFIG_MPEG2T_DEBUG, "Mpeg2tDebug", LOG_ALERT),
  CONFIG_INT(CONFIG_ASPECT_RATIO, "AspectRatio", 0),
  CONFIG_BOOL(CONFIG_FULL_SCREEN, "FullScreen", false),
  CONFIG_STRING_HELP(CONFIG_MULTICAST_RX_IF, "MulticastIf", NULL, "Physical interface to receive multicast"),
  CONFIG_INT_HELP(CONFIG_RX_SOCKET_SIZE, "RxSocketSize", 0, "Default receive buffer socket size"),
  CONFIG_STRING(CONFIG_MULTICAST_SRC, "MulticastSrc", NULL),
  CONFIG_STRING(CONFIG_LOG_FILE, "LogFile", NULL),
  CONFIG_BOOL_HELP(CONFIG_DISPLAY_DEBUG, "DisplayDebug", false, "In gmp4player, display status information every second"),
  CONFIG_INT(CONFIG_MPEG2PS_DEBUG, "Mpeg2psDebug", LOG_ALERT),
  CONFIG_STRING_HELP(CONFIG_URL_EXEC, "UrlExec", NULL, 
		     "Enter full path to browser launch - default /usr/bin/firefox/firefox"),
  CONFIG_BOOL(CONFIG_SHORT_VIDEO_RENDER, "ShortVideoRender", false),
  CONFIG_STRING_HELP(CONFIG_RTSP_PROXY_ADDR, "RtspProxyAddr", NULL, 
		     "RTSP proxy address"),
  CONFIG_INT(CONFIG_RTSP_PROXY_PORT, "RtspProxyPort", 0),
  CONFIG_STRING(CONFIG_OPENIPMPDRM_XMLFILE, "drmXML", NULL),
  CONFIG_STRING(CONFIG_OPENIPMPDRM_SENSITIVE, "drmInfo", NULL),
};


where SConfigVariable is

1
2
3
4
5
#ifdef _WIN32
#define SConfigVariableDeclare class
#else
#define SConfigVariableDeclare struct
#endif 


and

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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
SConfigVariableDeclare SConfigVariable {
#ifdef _WIN32
 public:	
  SConfigVariable(config_index_t *iName,
		  const char* 	 sName,
		  ConfigType	 type,
		  UConfigValue	 defaultValue,
		  const char *help = NULL,
		  UConfigValue	 value = (config_integer_t)0) {
    m_iName = iName;
    m_sName = sName;
    m_type = type;
    m_defaultValue = defaultValue;
    m_helpString = help;
    m_value = value;
  };
#endif

        config_index_t	               *m_iName;
	const char* 			m_sName;
	ConfigType			m_type;
	UConfigValue			m_defaultValue;
	const char*                     m_helpString;
	UConfigValue			m_value;

	const char* ToAscii() {
		static char sBuf[CONFIG_MAX_STRLEN+3];
		switch (m_type) {
		case CONFIG_TYPE_INTEGER:
			sprintf(sBuf, "%d", m_value.m_ivalue);
			return sBuf;
		case CONFIG_TYPE_BOOL:
			sprintf(sBuf, "%d", m_value.m_bvalue);
			return sBuf;
		case CONFIG_TYPE_STRING:
		  if(m_value.m_svalue == NULL) {
		    sprintf(sBuf, "\"\"");
		    return sBuf;
		  } 
			if (strchr(m_value.m_svalue, ' ')) {
				sBuf[0] = '"';
				strncpy(&sBuf[1], m_value.m_svalue, CONFIG_MAX_STRLEN);
				strcpy(&sBuf[
					MIN(strlen(m_value.m_svalue), CONFIG_MAX_STRLEN)+1], "\"");
			}
			return m_value.m_svalue;
		case CONFIG_TYPE_FLOAT:
			sprintf(sBuf, "%f", m_value.m_fvalue);
			return sBuf;
		default:
			return "";
		}
	}

	bool FromAscii(const char* s) {
		switch (m_type) {
		case CONFIG_TYPE_INTEGER:
			return (sscanf(s, " %i ", &m_value.m_ivalue) == 1);
		case CONFIG_TYPE_BOOL:
			// OPTION could add "yes/no", "true/false"
			if (sscanf(s, " %u ", &m_value.m_ivalue) != 1) {
				return false;
			}
			m_value.m_bvalue = m_value.m_ivalue ? true : false;
			return true;
		case CONFIG_TYPE_STRING:
			// N.B. assuming m_svalue has been alloc'ed
		  {
		    size_t len = strlen(s);
		    CHECK_AND_FREE(m_value.m_svalue);
		    if (*s == '"' && s[len] == '"') {
		      char *newvalue = strdup(s + 1);
		      newvalue[len - 1] = '\0';

		      m_value.m_svalue = newvalue;
		    } else {
		      m_value.m_svalue = strdup(s);
		    }
		    if (m_value.m_svalue == NULL) {
		      throw new CConfigException(CONFIG_ERR_MEMORY);
		    }
		    return true;
		  }
		case CONFIG_TYPE_FLOAT:
			return (sscanf(s, " %f ", &m_value.m_fvalue) == 1);
		default:
			return false;
		}
	}

	void SetToDefault(void) {
		switch (m_type) {
		case CONFIG_TYPE_INTEGER:
			m_value.m_ivalue = m_defaultValue.m_ivalue;
			break;
		case CONFIG_TYPE_BOOL:
			m_value.m_bvalue = m_defaultValue.m_bvalue;
			break;
		case CONFIG_TYPE_STRING:
			CHECK_AND_FREE(m_value.m_svalue);
			if (m_defaultValue.m_svalue == NULL) {
			  m_value.m_svalue = NULL;
			} else {
			  m_value.m_svalue = strdup(m_defaultValue.m_svalue);
			  if (m_value.m_svalue == NULL) {
			    throw new CConfigException(CONFIG_ERR_MEMORY);
			  }
			}
			break;
		case CONFIG_TYPE_FLOAT:
			m_value.m_fvalue = m_defaultValue.m_fvalue;
			break;
		default:
			break;
		} 
	}

	bool IsValueDefault(void) {
		switch (m_type) {
		case CONFIG_TYPE_INTEGER:
			return m_value.m_ivalue == m_defaultValue.m_ivalue;
		case CONFIG_TYPE_BOOL:
			return m_value.m_bvalue == m_defaultValue.m_bvalue;
		case CONFIG_TYPE_STRING:
		  if (m_defaultValue.m_svalue == NULL && m_value.m_svalue == NULL) 
		    return true;
		  if (m_defaultValue.m_svalue == NULL) return false;
		  if (m_value.m_svalue == NULL) return false;
			return (strcmp(m_value.m_svalue, m_defaultValue.m_svalue) == 0);
		case CONFIG_TYPE_FLOAT:
			return m_value.m_fvalue == m_defaultValue.m_fvalue;
		default:
			return false;
		} 
	}
        void CleanUpConfig(void) {
	  if (m_type == CONFIG_TYPE_STRING) {
	    CHECK_AND_FREE(m_value.m_svalue);
	  }
	}
};


i am not getting what is the problem. Can somebody tell me what is the problem?

Thanks
According to the C++ Standard "An aggregate is an array or a class (Clause 9) with no user-provided constructors (12.1),..."

As your class has a constructor it can not be initialized with the initializer list.
thanks vlad for the reply...

But as you can see there is s #ifdef _WIN32

so in my visual studio there is no such #defined. So that means it's a struct and it's have no constructor.

And one more thing it's a open source code, so i can not modified it, please suggest me something which i can do without modified code.

It's very important me to run this code.

Thanks
Last edited on
Are you sure that _WIN32 is not defined?
And check that other data members of your structure are aggregate.
since you asked the question, i rechecked it and yes _WIN32 is not defined anywhere.


ya but i have checked other data member and one more data member
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
union UConfigValue {
	UConfigValue(void) {
		m_svalue = NULL;
	}
	UConfigValue(config_integer_t ivalue) {
		m_ivalue = ivalue;
	}
	UConfigValue(bool bvalue) {
		m_bvalue = bvalue;
	}
  UConfigValue(const char *svalue) {
    m_svalue = svalue;
  }
	UConfigValue(char* svalue) {
		m_svalue = svalue;
	}
	UConfigValue(float fvalue) {
		m_fvalue = fvalue;
	}

	config_integer_t	m_ivalue;
	bool			m_bvalue;
	const char*		m_svalue;
	float				m_fvalue;
};


It's like that. Is it some problem in this?
The rest of the cited phrase of the Standard: "...no brace-or-equalinitializers
for non-static data members (9.2), no private or protected non-static data members (Clause 11),
no base classes (Clause 10), and no virtual functions (10.3)."
vlad, i got your point, but the problem is that, code is very big, and i don't have full knowledge of the code, so i can not do any changes......

can you please suggest something? It will be a great help.

Thanks
Last edited on
sorry vlad, just now i made some hit and try and i got it, it's compiling that _WIN32 part only, it's taking SConfigVariable as a class. Can you give some input on it.
Things can be defined by the compiler even if they are never defined in the code.
L B, thanks for the reply.

Yes you are right _WIN32 is compiler defined, that's why it's executing second option and giving error.
Topic archived. No new replies allowed.