13 February 2015, 03:01 | #1 |
Registered User
Join Date: Sep 2013
Location: Bettendorf, IA, USA
Age: 52
Posts: 204
|
OS3.9 -> OS4.1FE.....finally
So I have finally started to port my program from OS3.9 to OS4.1FE. I am running into a few issues right off the bat:
1) implicit declaration of function 'stpcpy', 'strset', 'stcd_l'. followed by 'incompatible implicit declaration of built-in function 'stpcpy' I did a quick search, no real help. Came across CoreUtils-src.lha on OS4Depot. Include their code chunks or a better way I am not finding? 2) How are STRPTR TheString and CONST_STRPTR TheString different? The only time I would see using CONST_STRPTR would be for the locale strings, never change. 3) uint32 NumAppStrings=sizeof(CatCompArray) / sizeof(struct CatCompArrayType); error: invalid application of 'sizeof' to imcomplete type 'struct CatCompArrayType[]' Works on SAS/C. To get number of strings in the CatComp array. 4) UBYTE Path[1024]; or go to uint8 Path[1024]; or STRPTR Path; How much can STRPTR hold? That's it for now.... Last edited by mritter0; 13 February 2015 at 03:11. |
16 February 2015, 05:29 | #2 |
Registered User
Join Date: Sep 2009
Location: the world
Posts: 439
|
I never coded in C/C++ specifically on Amiga, but regarding #3, I find it highly unlikely that any compiler would not give an error on that line.
sizeof cant work with incomplete types. "struct CatCompArrayType" just tells the compiler there's a struct named CatCompArrayType, there's no info on its contents so its size cannot be determined at compile time. Basically, the standard way of calculating the size of an array is this: int array[10]; int array_size = sizeof(array) / sizeof(array[0]); This calculation will work with any type of array. |
17 February 2015, 06:53 | #3 | |||
Banned
Join Date: Jan 2010
Location: Kansas
Posts: 1,284
|
Quote:
Quote:
Code:
#include <string.h> Code:
extern char *stpcpy(char *, const char *); Code:
char *stpcpy(char *resrtict to, const char *restrict from); Code:
char *stpcpy(char *, const char *); char * stpcpy (char *dst, const char *src) { while ((*dst++ = *src++)); return (dst-1); } strset() doesn't appear to be as popular. You can either search for an implementation on the internet or use a strlen()+memset(). stcd_l should probably be changed to strtol() if possible. http://en.cppreference.com/w/c/string/byte/strtol Quote:
Does #include <exec/types.h> no longer work with AmigaOS 4? You should be able to include this header to avoid needing to change from UBYTE to uint8. You would probably get errors if you changed this and then used with Amiga functions. STRPTR is just a pointer to data (a string) and doesn't hold any data other than the address to which it points. |
|||
18 February 2015, 04:21 | #4 |
Registered User
Join Date: Sep 2013
Location: Bettendorf, IA, USA
Age: 52
Posts: 204
|
@UberFreak: I think I found away around the sizeof() issue. I updated the code to not worry about the numer of strings. I will file that way, though.
@matthey: Yes, GCC. I didn't specify. For some reason strings.h is not in the GCC include_h folder. I copied it from VBCC's and it worked. It didn't give me an error it wasn't found so didn't go looking. Got around it with strcpy() and strcat() for what I was doing. strset() is not ANSI so not in GCC. I think ClearMem() might be what I need. stcd_l() to strtol() is what I used. I had it in another newer source file; just hadn't updated this one. I can now get my project to compile and link, but not run yet. But for some reason it says it can't find -lamiga. It can find/use -lauto. Or is it automatically linking it? |
18 February 2015, 06:03 | #5 | ||
Banned
Join Date: Jan 2010
Location: Kansas
Posts: 1,284
|
Quote:
It's significantly slower and probably twice as much code but that works. Quote:
Code:
#include <string.h> /* you need this for memset() and strlen() */ #define strset(s,c) memset(s,c,strlen(s)) It's quite possible that GCC doesn't need -lamiga. I have a project like that where vbcc needs to be linked with amiga.lib and my GCC 3.4.0 doesn't seem to need it. |
||
19 February 2015, 00:38 | #6 |
Registered User
Join Date: Sep 2013
Location: Bettendorf, IA, USA
Age: 52
Posts: 204
|
Getting most things worked out and updated. One thing that shocked me was the size of the executable. It went from 330K on OS3.9 to over 1.5MB on OS4. I expected at least a 64K jump, but not that much! What is up with that?!
I haven't gotten it to run and open the window yet. A couple things: In my Locale code to get the built-in or external catalog strings, this line Code:
String=GetCatalogStr(Catalog,ID,Builtin); The variable types all match. Code:
if (OpenDevice(TIMERNAME,UNIT_VBLANK,TimerIO,0)) TimerIO is: struct TimeRequest *TimerIO; EDIT: if (OpenDevice(TIMERNAME,UNIT_VBLANK,(struct IORequest *)TimerIO,0)) gets rid of the warning. Haven't tested it yet. I haven't dug too deep into this one. I know devices handles differently on OS4. These are the last 2 major warnings. Last edited by mritter0; 19 February 2015 at 00:47. |
19 February 2015, 06:44 | #7 | |
Banned
Join Date: Jan 2010
Location: Kansas
Posts: 1,284
|
Quote:
Code:
#include <proto/exec.h> #include <proto/dos.h> #include <proto/intuition.h> Most of your questions are getting into the AmigaOS 4 realm of which I don't know and have no experience. There are only a few people here on EAB who can help you. If they don't help, you might consider asking your AmigaOS 4 specific questions on Amigaworld.net. |
|
20 February 2015, 02:05 | #8 |
Registered User
Join Date: Sep 2013
Location: Bettendorf, IA, USA
Age: 52
Posts: 204
|
I was purposely not using any extra optimization for speed.
Before using -O2: 1602162 bytes After using -O2: 941726 bytes Still almost 3 times the size as OS3.9, but better. |
20 February 2015, 05:48 | #9 |
Banned
Join Date: Jan 2010
Location: Kansas
Posts: 1,284
|
Have you stripped the debug info or compiled without debug info? That can make quite some difference. I would expect 32 bit PPC code to be 40%-50% larger than 68k code. I could probably disassemble the 68k AmigaOS 3.9 version of your program and tell you how to get it down to 300kB but I'm not much help with PPC.
|
21 February 2015, 02:57 | #10 |
Registered User
Join Date: Sep 2013
Location: Bettendorf, IA, USA
Age: 52
Posts: 204
|
No debug turned on by me; no debug code put in by me. Does it need to be turned off? I would think it is off by default.
|
21 February 2015, 03:40 | #11 | |
Banned
Join Date: Jan 2010
Location: Kansas
Posts: 1,284
|
Quote:
You might try linking (LFLAGS) with -noixemul. I don't know if that is still important with AmigaOS 4. |
|
23 February 2015, 02:54 | #12 |
Registered User
Join Date: Sep 2013
Location: Bettendorf, IA, USA
Age: 52
Posts: 204
|
Here is a weird one that has me thrown for a loop:
Code:
int32 HistorySelected= -2; // set in globals.h ...... if (HistorySelected== -2) { ... } else { ... } If I display the value in a requester, it says it is -1803748384 (some crazy number). |
23 February 2015, 08:24 | #13 | |
Banned
Join Date: Jan 2010
Location: Kansas
Posts: 1,284
|
Quote:
Code:
int32_t HistorySelected= -2; // set in globals.h Code:
#include <stdint.h> Code:
extern int32_t HistorySelected; |
|
23 February 2015, 22:38 | #14 |
Registered User
Join Date: Sep 2013
Location: Bettendorf, IA, USA
Age: 52
Posts: 204
|
Didn't make any difference.
|
24 February 2015, 02:58 | #15 |
Banned
Join Date: Jan 2010
Location: Kansas
Posts: 1,284
|
You could try renaming the variable and see if it makes any difference. It's unlikely that there would be a name conflict with such a long variable name though. If you are good with a debugger and know a little PPC assembler, you might be able to see what is happening. I could probably give you a hint if the problem occurred with the 68k executable.
Edit: You could try deleting all the .o files that are generated by the build process and start the build again. Sometimes stale data or an incorrect build system will cause problems. Last edited by matthey; 24 February 2015 at 17:13. |
28 February 2015, 18:34 | #16 |
Registered User
Join Date: Sep 2013
Location: Bettendorf, IA, USA
Age: 52
Posts: 204
|
OMG....finally figured out what was going on with the -2 issue. I was setting it in globals.h, but then a portion of code I couldn't use under OS3.9 but now do under OS4.1FE, was setting it (or not setting it) to 0. Spent 3 days on this. Simplest things can be the most frustrating.
Thanks for the input and ideas, matthey. Last edited by mritter0; 28 February 2015 at 20:11. |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
DualPNG and OS4 icons on OS3 | James | Amiga scene | 31 | 15 February 2023 09:52 |
Replacing OS4 functions for OS3.x | arti | Coders. C/C++ | 25 | 17 December 2018 16:03 |
OS3.9 progs on OS4.1 | kkhard | support.WinUAE | 13 | 14 September 2014 02:17 |
Display 32bit OS4 Icons in Amiga OS3.x! | klesterjr | News | 12 | 28 February 2007 17:31 |
HivelyTracker 1.2 for OS4 and OS3.x out now! | spotUP | News | 5 | 08 January 2007 04:18 |
|
|