Could you help me to 1 - get rid of the warnings 2 - to use utf8 3 - polish (or rather fix) the code please
especially utf8 is way beyond me
Thank you
These are the warnings and the utf8 error
C++ backends/dialogs/amigaos/amigaos-dialogs.o
backends/dialogs/amigaos/amigaos-dialogs.cpp: In member function 'virtual Common::DialogManager::DialogResult AmigaOSDialogManager::showFileBrowser(const Common::U32String&, Common::FSNode&, bool)':
backends/dialogs/amigaos/amigaos-dialogs.cpp:44:18: warning: declaration of 'AslBase' shadows a global declaration [-Wshadow]
struct Library *AslBase = IExec->OpenLibrary("asl.library", 50);
^~~~~~~
In file included from backends/dialogs/amigaos/amigaos-dialogs.cpp:38:
/SDK/include/include_h/proto/asl.h:30:27: note: shadowed declaration is here
extern struct Library * AslBase;
^~~~~~~
backends/dialogs/amigaos/amigaos-dialogs.cpp:45:19: warning: declaration of 'IAsl' shadows a global declaration [-Wshadow]
struct AslIFace *IAsl = NULL;
^~~~
In file included from backends/dialogs/amigaos/amigaos-dialogs.cpp:38:
/SDK/include/include_h/proto/asl.h:47:27: note: shadowed declaration is here
extern struct AslIFace *IAsl;
^~~~
backends/dialogs/amigaos/amigaos-dialogs.cpp:65:56: warning: cast from type 'const value_type*' {aka 'const char*'} to type 'char*' casts away qualifiers [-Wcast-qual]
char *newTitle = utf8ToLocal((char *)utf8Title.c_str());
^
AR backends/libbackends.a
RANLIB backends/libbackends.a
C++ base/version.o
AR base/libbase.a
RANLIB base/libbase.a
LINK scummvm
backends/libbackends.a(amigaos-dialogs.o): In function `Common::SharedPtrDeletionInternal::~SharedPtrDeletionInternal()':
./common/ptr.h:43: undefined reference to `AmigaOSDialogManager::utf8ToLocal(char*)'
gmake: *** [scummvm] Error 1
and here is amigaos-dialogs.cpp
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
I need to add i have no idea how to incorporate the utf8 stuff
backends/dialogs/amigaos/amigaos-dialogs.cpp: In member function 'virtual Common::DialogManager::DialogResult AmigaOSDialogManager::showFileBrowser(const Common::U32String&, Common::FSNode&, bool)':
backends/dialogs/amigaos/amigaos-dialogs.cpp:67:56: warning: cast from type 'const value_type*' {aka 'const char*'} to type 'char*' casts away qualifiers [-Wcast-qual]
char *newTitle = utf8ToLocal((char *)utf8Title.c_str());
^
backends/libbackends.a(amigaos-dialogs.o): In function `Common::SharedPtrDeletionInternal::~SharedPtrDeletionInternal()':
./common/ptr.h:43: undefined reference to `AslBase'
./common/ptr.h:43: undefined reference to `AslBase'
./common/ptr.h:43: undefined reference to `AslBase'
./common/ptr.h:43: undefined reference to `IAsl'
./common/ptr.h:43: undefined reference to `IAsl'
./common/ptr.h:43: undefined reference to `IAsl'
./common/ptr.h:43: undefined reference to `AmigaOSDialogManager::utf8ToLocal(char*)'
./common/ptr.h:43: undefined reference to `IAsl'
./common/ptr.h:43: undefined reference to `IAsl'
./common/ptr.h:43: undefined reference to `IAsl'
./common/ptr.h:43: undefined reference to `AslBase'
gmake: *** [scummvm] Error 1
Maybe you need to put those definitions: extern struct Library *AslBase; extern struct AslIFace *IAsl; on top of amigaos-dialogs.cpp, before includes.
BTW I forget to "NULLify" ASL variables at end: Exec->DropInterface((struct Interface*)IAsl); IAsl = NULL; IExec->CloseLibrary(AslBase); AslBase = NULL;
Nope, still undefined refs on linking...the two extern structs are still inisde the if defined __amigaos4__
C++ backends/dialogs/amigaos/amigaos-dialogs.o
backends/dialogs/amigaos/amigaos-dialogs.cpp: In member function 'virtual Common::DialogManager::DialogResult AmigaOSDialogManager::showFileBrowser(const Common::U32String&, Common::FSNode&, bool)':
backends/dialogs/amigaos/amigaos-dialogs.cpp:67:56: warning: cast from type 'const value_type*' {aka 'const char*'} to type 'char*' casts away qualifiers [-Wcast-qual]
char *newTitle = utf8ToLocal((char *)utf8Title.c_str());
^
AR backends/libbackends.a
RANLIB backends/libbackends.a
C++ base/version.o
AR base/libbase.a
RANLIB base/libbase.a
LINK scummvm
backends/libbackends.a(amigaos-dialogs.o): In function `Common::SharedPtrDeletionInternal::~SharedPtrDeletionInternal()':
./common/ptr.h:43: undefined reference to `AslBase'
./common/ptr.h:43: undefined reference to `AslBase'
./common/ptr.h:43: undefined reference to `AslBase'
./common/ptr.h:43: undefined reference to `IAsl'
./common/ptr.h:43: undefined reference to `IAsl'
./common/ptr.h:43: undefined reference to `IAsl'
./common/ptr.h:43: undefined reference to `AmigaOSDialogManager::utf8ToLocal(char*)'
./common/ptr.h:43: undefined reference to `IAsl'
./common/ptr.h:43: undefined reference to `IAsl'
./common/ptr.h:43: undefined reference to `IAsl'
./common/ptr.h:43: undefined reference to `IAsl'
./common/ptr.h:43: undefined reference to `AslBase'
./common/ptr.h:43: undefined reference to `AslBase'
gmake: *** [scummvm] Error 1
Don't use "extern". Also move Asl symbols outside the function to avoid "shadowing" warnings. In proto/asl.h symbols are declared as globals that's why compiler was worried.
I managed to move around stuff so i get it to build without warnings, thanks a lot for the help
Now i'd like to implement the utf8 stuff (noob here aswell) but MorpHOS seems to use some stuff that is not available, or maybe i hvaenßt found it in the SDK (yet)?
struct Library *CodesetsBase = IExec->OpenLibrary("codesets.library", 6);
if (CodesetsBase) {
LONG dstmib = CSA_DestCodeset(NULL, 0);
if (dstmib != CS_MIBENUM_INVALID) {
LONG dstlen = FSGetByteSize((APTR)in, -1, CS_MIBENUM_UTF_8, dstmib);
char *out = (char *)malloc(dstlen + 1);
if (out) {
if (ConvertTagList((APTR)in, -1, (APTR)out, -1, CS_MIBENUM_UTF_8, dstmib, NULL) != -1) {
return out;
}
free(out);
}
}
IExec->CloseLibrary(CodesetsBase);
}
return strdup(in);
}
...
But i get compiler errors and warnings...do i miss an include, maybe?
Especially FSGetByteSize and ConvertTagList seem to be nowhere in my SDK.
And what does that "expression cannot be used as function" mean?
C++ backends/dialogs/amigaos/amigaos-dialogs.o
backends/dialogs/amigaos/amigaos-dialogs.cpp: In member function 'char* AmigaOSDialogManager::utf8ToLocal(char*)':
backends/dialogs/amigaos/amigaos-dialogs.cpp:52:40: error: expression cannot be used as a function
LONG dstmib = CSA_DestCodeset(NULL, 0);
^
backends/dialogs/amigaos/amigaos-dialogs.cpp:54:18: error: 'FSGetByteSize' was not declared in this scope
LONG dstlen = FSGetByteSize((APTR)in, -1, CS_MIBENUM_UTF_8, dstmib);
^~~~~~~~~~~~~
backends/dialogs/amigaos/amigaos-dialogs.cpp:54:18: note: suggested alternative: 'FSGetFileSize'
LONG dstlen = FSGetByteSize((APTR)in, -1, CS_MIBENUM_UTF_8, dstmib);
^~~~~~~~~~~~~
FSGetFileSize
backends/dialogs/amigaos/amigaos-dialogs.cpp:57:9: error: 'ConvertTagList' was not declared in this scope
if (ConvertTagList((APTR)in, -1, (APTR)out, -1, CS_MIBENUM_UTF_8, dstmib, NULL) != -1) {
^~~~~~~~~~~~~~
backends/dialogs/amigaos/amigaos-dialogs.cpp:57:9: note: suggested alternative: 'convertMsg'
if (ConvertTagList((APTR)in, -1, (APTR)out, -1, CS_MIBENUM_UTF_8, dstmib, NULL) != -1) {
^~~~~~~~~~~~~~
convertMsg
backends/dialogs/amigaos/amigaos-dialogs.cpp: In member function 'virtual Common::DialogManager::DialogResult AmigaOSDialogManager::showFileBrowser(const Common::U32String&, Common::FSNode&, bool)':
backends/dialogs/amigaos/amigaos-dialogs.cpp:93:56: warning: cast from type 'const value_type*' {aka 'const char*'} to type 'char*' casts away qualifiers [-Wcast-qual]
char *newTitle = utf8ToLocal((char *)utf8Title.c_str());
^
gmake: *** [backends/dialogs/amigaos/amigaos-dialogs.o] Error 1
Thanks for all the help guys, really appreciated...not that i'll learn much from it, but, yeah
You need to add IFace: struct CodesetsIFace *ICodesets = NULL; ... ICodesets = GetInterface((struct Library *)(Codesetbase), "main", 1L, NULL);
and close at exit/end: DropInterface( (struct Interface *)ICodesets ); ICodesets = NULL; ...
Are those missing functions part of MorphOS/OtherOS? Or part of your port/sources? If part of MorphOS, check MorphOS sdk autodocs and see such functions and then try to amigaos4'ize thrm.
EDIT: seems theyu a part of MorphOS charset autodoc: charsets.library/ConvertTagList() charsets.library/GetByteSize()
Yo can try to adapt parts in convert.c example (codesets archive) and replace in your port/sources.