From bfca537521e1ae112c64371e6d9e292ae26654ef Mon Sep 17 00:00:00 2001 From: "cls%seawood.org" Date: Thu, 18 Sep 2003 17:22:33 +0000 Subject: [PATCH] Fix misc build issues for mingw gcc 3.3.1: * Link non-component libs using -Wl,-enable-runtime-psuedo-relocs to workaround auto-import issues * the last element of an enum cannot end with a comma * PRUint16 is not interchangable with PRUnichar nor WCHAR * cannot take the address of or call ::main() from another c++ function * Functions declared within |class foo {};| block do not need extra |foo::| qualification * GCC no longer implements . Use instead Bug #217009 sr=dbaron --- config/rules.mk | 2 +- dom/src/base/nsJSEnvironment.cpp | 2 +- gfx/src/windows/nsFontMetricsWin.cpp | 14 +++++++------- gfx/src/windows/nsFontMetricsWin.h | 2 +- mailnews/base/src/nsMessengerWinIntegration.cpp | 2 +- netwerk/base/src/nsAutodialWin.h | 4 ++-- netwerk/protocol/http/src/nsHttpNTLMAuth.cpp | 6 +++--- uriloader/exthandler/win/nsOSHelperAppService.cpp | 2 +- webshell/tests/viewer/nsWinMain.cpp | 2 ++ widget/src/windows/nsWindow.cpp | 3 ++- xpfe/bootstrap/nsAppRunner.cpp | 2 +- xpfe/bootstrap/nsNativeAppSupportWin.cpp | 2 +- xpfe/components/history/src/nsGlobalHistory.cpp | 4 ++-- xpinstall/src/nsInstall.cpp | 2 +- xpinstall/src/nsInstallFolder.cpp | 4 ++-- 15 files changed, 28 insertions(+), 25 deletions(-) diff --git a/config/rules.mk b/config/rules.mk index f5206ed5987..190b79bc0a0 100644 --- a/config/rules.mk +++ b/config/rules.mk @@ -521,7 +521,7 @@ endif ifeq ($(OS_ARCH),WINNT) ifdef GNU_CC ifndef IS_COMPONENT -DSO_LDOPTS += -Wl,--export-all-symbols -Wl,--out-implib -Wl,$(IMPORT_LIBRARY) +DSO_LDOPTS += -Wl,--export-all-symbols -Wl,--out-implib -Wl,$(IMPORT_LIBRARY) -Wl,-enable-runtime-pseudo-reloc endif endif endif diff --git a/dom/src/base/nsJSEnvironment.cpp b/dom/src/base/nsJSEnvironment.cpp index 0e63245bd0e..07c3aa998f1 100644 --- a/dom/src/base/nsJSEnvironment.cpp +++ b/dom/src/base/nsJSEnvironment.cpp @@ -309,7 +309,7 @@ ChangeCase(JSContext *cx, JSString *src, jsval *rval, nsAutoString result; changeCaseFnc(str, result); - JSString *ucstr = JS_NewUCStringCopyN(cx, result.get(), result.Length()); + JSString *ucstr = JS_NewUCStringCopyN(cx, (jschar*)result.get(), result.Length()); if (!ucstr) { return JS_FALSE; } diff --git a/gfx/src/windows/nsFontMetricsWin.cpp b/gfx/src/windows/nsFontMetricsWin.cpp index 5a55fea3442..8f6a1b2ee3b 100644 --- a/gfx/src/windows/nsFontMetricsWin.cpp +++ b/gfx/src/windows/nsFontMetricsWin.cpp @@ -1476,7 +1476,7 @@ enum { eTTFormat6TrimmedTableMapping = 6, eTTFormat8Mixed16bitAnd32bitCoverage = 8, eTTFormat10TrimmedArray = 10, - eTTFormat12SegmentedCoverage = 12, + eTTFormat12SegmentedCoverage = 12 }; static void @@ -1939,7 +1939,7 @@ GetGlyphIndices(HDC aDC, PRUint16* idDelta = startCode + segCount; PRUint16* idRangeOffset = idDelta + segCount; - PRUint16* result = aResult.GetArray(aLength); + PRUnichar* result = aResult.GetArray(aLength); if (!result) { return NS_ERROR_OUT_OF_MEMORY; } @@ -4255,7 +4255,7 @@ nsFontWinNonUnicode::GetBoundingMetrics(HDC aDC, if (gGlyphAgent.GetState() != eGlyphAgent_UNICODE) { // we are on a platform that doesn't implement GetGlyphOutlineW() // we need to use glyph indices - rv = GetGlyphIndices(aDC, &mCMAP, (PRUint16*) buffer.GetArray(), destLength / 2, buf); + rv = GetGlyphIndices(aDC, &mCMAP, (PRUnichar*)buffer.GetArray(), destLength / 2, buf); if (NS_FAILED(rv)) { return rv; } @@ -4263,7 +4263,7 @@ nsFontWinNonUnicode::GetBoundingMetrics(HDC aDC, // buffer.mBuffer is now a pseudo-Unicode string so that we can use // GetBoundingMetricsCommon() also used by nsFontWinUnicode. - return GetBoundingMetricsCommon(aDC, mOverhangCorrection, (PRUint16*) buffer.GetArray(), + return GetBoundingMetricsCommon(aDC, mOverhangCorrection, (PRUnichar*)buffer.GetArray(), destLength / 2, aBoundingMetrics, buf.GetArray()); } @@ -4437,7 +4437,7 @@ GenerateSingleByte(nsCharsetInfo* aSelf) { PRUint32 map[UCS2_MAP_LEN]; PRUint8 mb[256]; - PRUint16 wc[256]; + WCHAR wc[256]; int i; memset(map, 0, sizeof(map)); @@ -4485,7 +4485,7 @@ GenerateMultiByte(nsCharsetInfo* aSelf) { PRUint32 map[UCS2_MAP_LEN]; memset(map, 0, sizeof(map)); - for (PRUint16 c = 0; c < 0xFFFF; ++c) { + for (WCHAR c = 0; c < 0xFFFF; ++c) { BOOL defaulted = FALSE; WideCharToMultiByte(aSelf->mCodePage, 0, &c, 1, nsnull, 0, nsnull, &defaulted); @@ -4499,7 +4499,7 @@ GenerateMultiByte(nsCharsetInfo* aSelf) static int HaveConverterFor(PRUint8 aCharset) { - PRUint16 wc = 'a'; + WCHAR wc = 'a'; char mb[8]; if (WideCharToMultiByte(gCharsetInfo[gCharsetToIndex[aCharset]].mCodePage, 0, &wc, 1, mb, sizeof(mb), nsnull, nsnull)) { diff --git a/gfx/src/windows/nsFontMetricsWin.h b/gfx/src/windows/nsFontMetricsWin.h index eae7c2abfad..83097b5a5e3 100644 --- a/gfx/src/windows/nsFontMetricsWin.h +++ b/gfx/src/windows/nsFontMetricsWin.h @@ -44,7 +44,7 @@ enum eFontType { eFontType_UNKNOWN = -1, eFontType_Unicode, - eFontType_NonUnicode, + eFontType_NonUnicode }; struct nsCharacterMap { diff --git a/mailnews/base/src/nsMessengerWinIntegration.cpp b/mailnews/base/src/nsMessengerWinIntegration.cpp index fc1228ec261..3f8c53901ea 100644 --- a/mailnews/base/src/nsMessengerWinIntegration.cpp +++ b/mailnews/base/src/nsMessengerWinIntegration.cpp @@ -454,7 +454,7 @@ nsMessengerWinIntegration::Init() // get application path char appPath[_MAX_PATH] = {0}; GetModuleFileName(nsnull, appPath, sizeof(appPath)); - WORD wideFormatAppPath[_MAX_PATH*2] = {0}; + WCHAR wideFormatAppPath[_MAX_PATH*2] = {0}; MultiByteToWideChar(CP_ACP, 0, appPath, strlen(appPath), wideFormatAppPath, _MAX_PATH*2); mAppName.Assign((PRUnichar *)wideFormatAppPath); diff --git a/netwerk/base/src/nsAutodialWin.h b/netwerk/base/src/nsAutodialWin.h index 628467b395f..36f7bc64dd4 100644 --- a/netwerk/base/src/nsAutodialWin.h +++ b/netwerk/base/src/nsAutodialWin.h @@ -167,8 +167,8 @@ private: static tRASGETAUTODIALENABLE mpRasGetAutodialEnable; static tRASGETAUTODIALPARAM mpRasGetAutodialParam; - PRBool nsRASAutodial::LoadRASapi32DLL(); - PRBool nsRASAutodial::LoadRASdlgDLL(); + PRBool LoadRASapi32DLL(); + PRBool LoadRASdlgDLL(); public: diff --git a/netwerk/protocol/http/src/nsHttpNTLMAuth.cpp b/netwerk/protocol/http/src/nsHttpNTLMAuth.cpp index d62c6a02d96..e82dd9e12f8 100644 --- a/netwerk/protocol/http/src/nsHttpNTLMAuth.cpp +++ b/netwerk/protocol/http/src/nsHttpNTLMAuth.cpp @@ -318,11 +318,11 @@ nsHttpNTLMAuth::GenerateCredentials(nsIHttpChannel *httpChannel, pIdent = &identA; } else { - identW.User = (PRUnichar *) user; + identW.User = (unsigned short *) user; identW.UserLength = nsCRT::strlen(user); - identW.Domain = (PRUnichar *) domain; + identW.Domain = (unsigned short *) domain; identW.DomainLength = nsCRT::strlen(domain); - identW.Password = (PRUnichar *) pass; + identW.Password = (unsigned short *) pass; identW.PasswordLength = nsCRT::strlen(pass); identW.Flags = SEC_WINNT_AUTH_IDENTITY_UNICODE; pIdent = &identW; diff --git a/uriloader/exthandler/win/nsOSHelperAppService.cpp b/uriloader/exthandler/win/nsOSHelperAppService.cpp index fc7dce079e7..a8a3e3afb1f 100644 --- a/uriloader/exthandler/win/nsOSHelperAppService.cpp +++ b/uriloader/exthandler/win/nsOSHelperAppService.cpp @@ -41,7 +41,7 @@ #define LOG(args) PR_LOG(mLog, PR_LOG_DEBUG, args) // helper methods: forward declarations... -BYTE * GetValueBytes( HKEY hKey, const char *pValueName, DWORD *pLen=0); +static BYTE * GetValueBytes( HKEY hKey, const char *pValueName, DWORD *pLen=0); nsresult GetExtensionFrom4xRegistryInfo(const char * aMimeType, nsCString& aFileExtension); nsresult GetExtensionFromWindowsMimeDatabase(const char * aMimeType, nsCString& aFileExtension); diff --git a/webshell/tests/viewer/nsWinMain.cpp b/webshell/tests/viewer/nsWinMain.cpp index cec45267bfe..78168a2da43 100644 --- a/webshell/tests/viewer/nsWinMain.cpp +++ b/webshell/tests/viewer/nsWinMain.cpp @@ -160,6 +160,7 @@ int main(int argc, char **argv) return result; } +#ifndef __GNUC__ int PASCAL WinMain(HINSTANCE instance, HINSTANCE prevInstance, LPSTR cmdParam, int nCmdShow) @@ -168,3 +169,4 @@ WinMain(HINSTANCE instance, HINSTANCE prevInstance, LPSTR cmdParam, gPrevInstance = prevInstance; return main(0, nsnull); } +#endif diff --git a/widget/src/windows/nsWindow.cpp b/widget/src/windows/nsWindow.cpp index 0fcea6b8f80..51fd5fc513e 100644 --- a/widget/src/windows/nsWindow.cpp +++ b/widget/src/windows/nsWindow.cpp @@ -6598,7 +6598,8 @@ nsWindow::HandleMouseActionOfIME(int aAction, POINT *ptPos) // Note: hitText has been done, so no check of mIMECompCharPos // and composing char maximum limit is necessary. - for (PRInt32 i = 0; i < mIMECompUnicode->Length(); i++) { + PRInt32 i = 0; + for (i = 0; i < mIMECompUnicode->Length(); i++) { if (PT_IN_RECT(*ptPos, mIMECompCharPos[i])) break; } diff --git a/xpfe/bootstrap/nsAppRunner.cpp b/xpfe/bootstrap/nsAppRunner.cpp index 78fd796ca68..f5cd64359b0 100644 --- a/xpfe/bootstrap/nsAppRunner.cpp +++ b/xpfe/bootstrap/nsAppRunner.cpp @@ -1680,7 +1680,7 @@ int main(int argc, char* argv[]) return TranslateReturnValue(mainResult); } -#if defined( XP_WIN ) && defined( WIN32 ) +#if defined( XP_WIN ) && defined( WIN32 ) && !defined(__GNUC__) // We need WinMain in order to not be a console app. This function is // unused if we are a console application. int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR args, int) diff --git a/xpfe/bootstrap/nsNativeAppSupportWin.cpp b/xpfe/bootstrap/nsNativeAppSupportWin.cpp index 0bc007d7661..5c8b2d80b32 100644 --- a/xpfe/bootstrap/nsNativeAppSupportWin.cpp +++ b/xpfe/bootstrap/nsNativeAppSupportWin.cpp @@ -1062,7 +1062,7 @@ nsNativeAppSupportWin::Start( PRBool *aResult ) { PRBool nsNativeAppSupportWin::InitTopicStrings() { for ( int i = 0; i < topicCount; i++ ) { - if ( !( mTopics[ i ] = DdeCreateStringHandle( mInstance, topicNames[ i ], CP_WINANSI ) ) ) { + if ( !( mTopics[ i ] = DdeCreateStringHandle( mInstance, NS_CONST_CAST(char *,topicNames[ i ]), CP_WINANSI ) ) ) { return PR_FALSE; } } diff --git a/xpfe/components/history/src/nsGlobalHistory.cpp b/xpfe/components/history/src/nsGlobalHistory.cpp index f0ab0f6893c..e6eb2d8da27 100644 --- a/xpfe/components/history/src/nsGlobalHistory.cpp +++ b/xpfe/components/history/src/nsGlobalHistory.cpp @@ -891,8 +891,8 @@ nsGlobalHistory::SwapBytes(const PRUnichar *source, PRUnichar *dest, PRInt32 aLen) { PRUint16 c; - const PRUint16 *inp; - PRUint16 *outp; + const PRUnichar *inp; + PRUnichar *outp; PRInt32 i; inp = source; diff --git a/xpinstall/src/nsInstall.cpp b/xpinstall/src/nsInstall.cpp index 2098eb98699..f5921e41b48 100644 --- a/xpinstall/src/nsInstall.cpp +++ b/xpinstall/src/nsInstall.cpp @@ -1256,7 +1256,7 @@ nsInstall::LoadResources(JSContext* cx, const nsString& aBaseName, jsval* aRetur JSString* propValJSStr = JS_NewUCStringCopyZ(cx, NS_REINTERPRET_CAST(const jschar*, pVal.get())); jsval propValJSVal = STRING_TO_JSVAL(propValJSStr); nsString UCKey = NS_ConvertUTF8toUCS2(pKey); - JS_SetUCProperty(cx, res, UCKey.get(), UCKey.Length(), &propValJSVal); + JS_SetUCProperty(cx, res, (jschar*)UCKey.get(), UCKey.Length(), &propValJSVal); } } diff --git a/xpinstall/src/nsInstallFolder.cpp b/xpinstall/src/nsInstallFolder.cpp index 35a2e39c6f9..3299d4ec62a 100644 --- a/xpinstall/src/nsInstallFolder.cpp +++ b/xpinstall/src/nsInstallFolder.cpp @@ -43,7 +43,7 @@ #include "nsAppDirectoryServiceDefs.h" #ifdef XP_WIN -#include +#include #include #include #endif @@ -401,7 +401,7 @@ nsInstallFolder::SetDirectoryPath(const nsAString& aFolderID, const nsString& aR BYTE path[_MAX_PATH + 1] = { 0 }; DWORD type; DWORD pathlen = sizeof(path); - char *value = (dirID==WIN_PROGRAM_FILES) ? + const char *value = (dirID==WIN_PROGRAM_FILES) ? "ProgramFilesDir" : "CommonFilesDir"; result = RegQueryValueEx( key, value, 0, &type, path, &pathlen );