소스 검색

Initialize structures with non-const initialzers

This is a warning on MSVC when not using Microsoft extensions.

> C4204: nonstandard extension used: non-constant aggregate initializer

Apparently struct a = {blah}; is invalid for ANSI compatibility on MSVC.
Matt Clarkson 10 년 전
부모
커밋
e388305907
1개의 변경된 파일8개의 추가작업 그리고 3개의 파일을 삭제
  1. 8 3
      src/main.c

+ 8 - 3
src/main.c

@@ -1173,7 +1173,9 @@ static int get_password(const char *user,
 	unsigned char mem[4096], *p;
 	DLGTEMPLATE *dia = (DLGTEMPLATE *)mem;
 	int ok, y;
-	struct tstring_input_buf dlgprms = {passwd_len, passwd};
+	struct tstring_input_buf dlgprms;
+	dlgprms.buffer = passwd;
+	dlgprms.buflen = passwd_len;
 
 	static struct {
 		DLGTEMPLATE template; /* 18 bytes */
@@ -1809,7 +1811,8 @@ static int manage_service(int action)
 	static const char *service_name =
 	    "Civetweb"; /* TODO: check using server_name instead of service_name */
 	SC_HANDLE hSCM = NULL, hService = NULL;
-	SERVICE_DESCRIPTION descr = {g_server_name};
+	SERVICE_DESCRIPTION descr;
+	descr.lpDescription = g_server_name;
 	char path[PATH_MAX + 20] = ""; /* Path to executable plus magic argument */
 	int success = 1;
 
@@ -1866,7 +1869,9 @@ WindowProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
 {
 	static SERVICE_TABLE_ENTRY service_table[2];
 	int service_installed;
-	char buf[200], *service_argv[] = {__argv[0], NULL};
+	char buf[200], *service_argv[2];
+	service_argv[0] = __argv[0];
+	service_argv[1] = NULL;
 	POINT pt;
 	HMENU hMenu;
 	static UINT s_uTaskbarRestart; /* for taskbar creation */