![]() |
![]() |
![]() |
#1 |
Registered User
![]() Join Date: May 2022
Location: Adelaide
Posts: 81
|
Visual Studio Code Amiga C Extension
I'm having problems with includes. As far as I can tell, I just include
<proto/xxx>for whatever library I want to use. However including <proto/alib.h>throws a ton of errors. Attached is the output when I try to build with it included. Although, I would appreciate if someone would point me to working implementations of CreateExtIO()and DeleteExtIO(), because I'd be just fine programming them in myself, but I can't figure out what needs to be initialised in the IORequeststructure. I've already made my own CreatePort()and DeletePort(). ![]() ![]() |
![]() |
![]() |
#2 |
Registered User
![]() Join Date: Jun 2016
Location: europe
Posts: 806
|
Something like:
Code:
createextio(reply_port, size): io = AllocMem(size,MEMF_CLEAR|MEMF_PUBLIC); // handle failed alloc io->io_Message.mn_Node.ln_Type = NT_REPLYMSG; io->io_Message.mn_Length = size; io->io_Message.mn_ReplyPort = reply_port; return io; deleteextio(io): if (io) FreeMem(io,io->io_Message.mn_Length); |
![]() |
![]() |
#3 | |
Registered User
![]() Join Date: May 2022
Location: Adelaide
Posts: 81
|
Quote:
PS: Also do I have to abort the IORequest before removing it? The documentation says it's dangerous to abort a request that's never been used, how do I check if it's been used or not? Last edited by Steam Ranger; 24 January 2023 at 08:10. |
|
![]() |
![]() |
#4 |
Registered User
![]() Join Date: Jun 2016
Location: europe
Posts: 806
|
Yeah, NT_REPLYMSG tells that the previous I/O had been replied and is fully complete, and the request is ready for another or to be freed. Length is there so that you know whether it's standard, extended, etc. (how much extra data is there). ReplyPort is optional, it's there because typically it's always the same one so you fill it in once.
Other properties you have to fill in prior to doing an actual I/O, based on device, I/O type, etc. You should only (try to, since it's not a 100% guarantee, there are device specific considerations) abort if it's in progress (if you haven't replied yet). If the type is set to NT_REPLYMSG, as I mentioned above, it's done. |
![]() |
![]() |
#5 |
Registered User
![]() Join Date: May 2022
Location: Adelaide
Posts: 81
|
I'm running into a problem with the timer device.
Here's the code I'm using to open it: Code:
Devices.h Code:
Timer.h TimerBase, and yet when GetSysTime()is called it gives this in a pop-up: Failed to get Stack Trace: Cannot access memory at address 0xaea00f8 (from data-disassemble -s 0x0aea00f8 -e 0x0aea015c -- 5) And outputs this: B-Trap FFFF at 000A9CD2 -> 00F80AE8 Please help... ![]() ![]() |
![]() |
![]() |
#6 |
Registered User
![]() Join Date: Jun 2016
Location: europe
Posts: 806
|
Probably not related, but...
1. NewList macro is not using its parameter list, looks like there's a hardcoded outside variable in the first line, right-hand side. It should probably be: struct List *_NewList_list = list; 2. NewList macro again, why ({...})? () is typically associated with function calls, you should probably only use {} |
![]() |
![]() |
#7 |
Registered User
![]() Join Date: May 2022
Location: Adelaide
Posts: 81
|
I copied character for character the existing newlist macro, as for whatever reason the one in my includes wasn't working.
|
![]() |
![]() |
#8 |
Registered User
![]() Join Date: May 2022
Location: Adelaide
Posts: 81
|
Here's
Timer.hand Devices.h, incase more info is needed. I cannot figure out why this isn't working, especially since no part of the opening process gives an error. It just all worked correctly and then WinUAE Error 3. They've got *.cextensions just so I can upload them, but they're *.hFiles. |
![]() |
![]() |
#9 |
Registered User
![]() Join Date: Jun 2016
Location: europe
Posts: 806
|
AbortIOInProgress should use != instead of == (you're aborting if type == NT_REPLYMSG).
And again, what is the purpose of ({...})? After NewList macro expansion you end up with if (...) {...} else ({...}) instead of if (...) {...} else {...} I don't know what compiler you're using, if it's a gcc port it could be OK since this is not a valid c, it's a gcc extension, and I don't know what will other compilers produce. In any case there's no need for () because, as far as I can see, macro is not intended to be used as a right-hand expression (it would always "return" 0). |
![]() |
![]() |
#10 |
Registered User
Join Date: Jan 2019
Location: Germany
Posts: 2,270
|
Is there actually a reason why you don't use NewList() in amiga.lib, CreateMsgPort() in exec and CreateExtIO() in exec? Or their corresponding counterparts from amiga.lib?
|
![]() |
![]() |
#11 |
Registered User
![]() Join Date: May 2022
Location: Adelaide
Posts: 81
|
Whenever I include it it throws errors because of
_stdargsor something before every function definition, but if I splice those out of the file the functions fail. So I decided to make my own set of functions, which also has the benefit that I can tweak them to have additional features. PS: NewListby default expands to have those brackets around it, but even once I've removed them it doesn't alter the functionality one bit. Also, I'm using gcc 8. Last edited by Steam Ranger; 26 January 2023 at 02:43. Reason: PS |
![]() |
![]() |
#12 |
Registered User
![]() Join Date: May 2022
Location: Adelaide
Posts: 81
|
Ah, I just realised. In
GetTimestamp()my intention was to create a struct timevalin stack memory, pass a pointer to it into GetSysTime()and then return some values from it. I forgot that declaring a pointer to the structure doesn't create it, but instead you have to declare the structure and use &to get a pointer. Thanks for your help anyway. ![]() Last edited by Steam Ranger; 26 January 2023 at 12:56. Reason: Smiley |
![]() |
![]() |
#13 | |||
Natteravn
![]() Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,290
|
Quote:
__stdargsas in clib/compiler_specific.h: Code:
#if (defined(__GNUC__) && defined(AMIGA)) || defined(__SASC) #define __STDARGS__ __stdargs Quote:
_stdargsattribute is for those compilers which don't. Which makes it especially annoying when such an attribute is missing. Maybe there is an option for the command line? Quote:
![]() Or switch to a more compatible compiler. My observation is that the version of a gcc-port directly correlates to the incompatibility with classic AmigaOS compilers. ![]() |
|||
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Amiga GCC 8.3+gdb extension for Visual Studio Code | Bartman | Coders. C/C++ | 104 | 06 November 2022 18:49 |
Amiga Assembly extension for Visual Studio Code | prb28 | Coders. Asm / Hardware | 316 | 17 August 2022 18:01 |
Issue getting started with amiga-debug Visual Studio Code Extension (Windows) | dalton | Coders. General | 2 | 23 June 2022 22:02 |
Amiga Assembly exension for Visual Studio Code 0.19 released | prb28 | Coders. General | 2 | 02 January 2020 19:34 |
Visual Studio Code Blitz Basic extension | earok | Coders. Blitz Basic | 29 | 16 July 2019 18:59 |
|
|