![]() |
![]() |
![]() |
#1 |
Returning fan!
![]() Join Date: Jan 2011
Location: Montréal, QC, Canada
Posts: 851
|
NetLib for StormC
Hi all!
So, Tumo and I made great progress in compiling AmiModRadio with StormC, hopefully to use its debugger and debug crashes on Honx's and Tumo's configs... Now, one last step: linking AmiModRadio with AmiTCP net.lib... The problem here is that AmiTCP provides a version of net.lib for SAS/C and it seems difficult for me to compile its source with StormC... Has anyone a version of net.lib for StormC? I guess that I am not the first one to want sockets in StormC ![]() Thanks in advance! |
![]() |
![]() |
#2 |
Registered User
Join Date: Jan 2005
Location: Umeå
Age: 40
Posts: 598
|
Unless you have a need for the extra functions available in net.lib, you should be fine by just opening bsdsocket.library and including <proto/socket.h> and at least <sys/socket.h>.
|
![]() |
![]() |
#3 |
Returning fan!
![]() Join Date: Jan 2011
Location: Montréal, QC, Canada
Posts: 851
|
Hi Patrik!
Thanks for your help! This is what I did, I included: clib/socket_protos.h sys/socket.h and my code compiles fine but at linking time, functions like connect recv ... are missing... Am I doing something wrong? ![]() Thanks! Last edited by tygre; 15 April 2017 at 19:50. Reason: Completed post |
![]() |
![]() |
#4 |
Returning fan!
![]() Join Date: Jan 2011
Location: Montréal, QC, Canada
Posts: 851
|
PS. Replacing clib/socket_proto.h by proto/socket.h makes no difference: still some functions are missing at linking time
![]() |
![]() |
![]() |
#5 |
Registered User
Join Date: Jan 2005
Location: Umeå
Age: 40
Posts: 598
|
Sorry, I should not have "helped" as I have no experience with StormC. However, I have used bsdsocket.library both with SAS/C and VBCC for more than ten years without linking with net.lib, using the method above, which should work as it is a library like any other.
|
![]() |
![]() |
#6 |
Returning fan!
![]() Join Date: Jan 2011
Location: Montréal, QC, Canada
Posts: 851
|
Yes, indeed, my code compiles fine with VBCC... I have as libraries:
Thanks! ![]() |
![]() |
![]() |
#7 |
Registered User
Join Date: Jan 2005
Location: Umeå
Age: 40
Posts: 598
|
Take everything below with a grain of salt as I might have missed several aspects/details.
Normally with vbcc I don't link with any specific link libraries unless I need some function or data from them. The only thing vbcc links with automatically then is vc.lib. Say if I wanted to use NewList() from amiga.lib, then I would link it, but otherwise not. This is when using <proto/xyz.h> though, which I have understood defines the library functions in such way that the compiler will put the arguments for the library function in the correct registers as specified in the autodoc and call the function directly, which is the most efficient way to do it. How to do it is compiler specific (vbcc for example has a proto directory supplied with such files for all amigaos libraries for example). If you use clib/proto_xyz.h>, the library functions will be defined as normal C functions where the arguments normally are passed on the stack, which requires some stub/wrapper code to do the actual library function call with registers correctly populated. These stubs/wrappers are as far as I know supplied in link libraries. I think amiga.lib for example contains all such stubs /wrappers for the amigaos library functions. I would assume net.lib also got the stubs/wrappers for bsdsocket.library apart from the actual functions it itself contains. Btw, I have been using the Roadshow SDK for bsdsocket.library code for quite a while and it doesn't even include a net.lib, so I guess it assumes you would want to use <proto/socket.h>. |
![]() |
![]() |
#8 | ||||
Returning fan!
![]() Join Date: Jan 2011
Location: Montréal, QC, Canada
Posts: 851
|
Hi Patrik!
Quote:
![]() Quote:
Quote:
#include <stdio.h> #include <stdlib.h> #include <dos/dos.h> // For RETURN_OK, RETURN_ERROR #include <sys/types.h> // For u_short #include <proto/exec.h> // For OpenLibrary() and CloseLibrary() #include <netdb.h> // Sockets and such #include <proto/socket.h> // Sockets and such #include <sys/socket.h> // Sockets and such What am I missing? Again, with VBCC, it compiles fine... only with StormC... I must be overlooking something... Quote:
![]() Cheers! |
||||
![]() |
![]() |
#9 |
Coder/webmaster/gamer
Join Date: Oct 2001
Location: Canberra/Australia
Posts: 2,208
|
You don't need net.lib for send(), recv(), etc.
You might want to look at the source code for the Report+ application (http://amigan.1emu.net/releases/ReportPlus.lha); it is written for StormC and has full source included. |
![]() |
![]() |
#10 | |
Registered User
Join Date: Jan 2005
Location: Umeå
Age: 40
Posts: 598
|
Quote:
Which bsdsocket.library SDK are you using? |
|
![]() |
![]() |
#11 | |
Returning fan!
![]() Join Date: Jan 2011
Location: Montréal, QC, Canada
Posts: 851
|
Quote:
![]() Cheers! |
|
![]() |
![]() |
#12 | |
Returning fan!
![]() Join Date: Jan 2011
Location: Montréal, QC, Canada
Posts: 851
|
Quote:
Cheers! |
|
![]() |
![]() |
#13 |
Coder/webmaster/gamer
Join Date: Oct 2001
Location: Canberra/Australia
Posts: 2,208
|
|
![]() |
![]() |
#14 | |
Registered User
Join Date: Jan 2005
Location: Umeå
Age: 40
Posts: 598
|
Quote:
It is also possible to generate missing protos for more or less any compiler from .fd files which should be included in the SDK. I don't know what tool to use for StormC, but with vbcc you use the included fd2pragma for example. Should be a chapter about this in the StormC3 manual. |
|
![]() |
![]() |
#15 | |
Returning fan!
![]() Join Date: Jan 2011
Location: Montréal, QC, Canada
Posts: 851
|
Hi Minuous and Patrik!
Quote:
![]() I'll keep you posted! Cheers! |
|
![]() |
![]() |
#16 | |
Returning fan!
![]() Join Date: Jan 2011
Location: Montréal, QC, Canada
Posts: 851
|
Quote:
Was ReportPlus written with StormC 4? I tried to load its project file (.¶) in StormC 3 and it complains that the file is "not a project file"? ![]() Cheers! |
|
![]() |
![]() |
#17 |
Coder/webmaster/gamer
Join Date: Oct 2001
Location: Canberra/Australia
Posts: 2,208
|
Yes, it was written with StormC 4, but it uses the StormC 3 compiler.
|
![]() |
![]() |
#18 |
Returning fan!
![]() Join Date: Jan 2011
Location: Montréal, QC, Canada
Posts: 851
|
Hi Minuous!
I looked at the code and I think that I understand why ReportPlus compiles with StormC 3: it "defines" the libcalls in the C files. For example, at the beginning of f1.c, there is: Code:
struct hostent* gethostbyname(const UBYTE* name); LONG recv(LONG s, UBYTE* buf, LONG len, LONG flags); /* V3 */ LONG closesocket(LONG d); LONG connect(LONG s, const struct sockaddr* name, LONG namelen); LONG send(LONG s, const UBYTE* msg, LONG len, LONG flags); LONG socket(LONG domain, LONG type, LONG protocol); LONG shutdown(LONG s, LONG how); #pragma libcall SocketBase gethostbyname D2 801 #pragma libcall SocketBase recv 4E 218004 #pragma libcall SocketBase closesocket 78 001 #pragma libcall SocketBase connect 36 18003 #pragma libcall SocketBase send 42 218004 #pragma libcall SocketBase socket 1E 21003 #pragma libcall SocketBase shutdown 54 1002 ![]() Cheers! Last edited by tygre; 18 May 2017 at 02:17. |
![]() |
![]() |
#19 |
Coder/webmaster/gamer
Join Date: Oct 2001
Location: Canberra/Australia
Posts: 2,208
|
I don't recall the exact reason why I did it that way. It's generally considered better to use include files. Presumably there was some issue with the include file/compiler/linker etc. that made this the easiest way. Either way, of course, the resulting executable will be the same.
|
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
dirent.h in StormC v3.0 | tygre | Coders. C/C++ | 6 | 19 April 2017 01:34 |
StormC PPC | fryguy | request.Apps | 1 | 17 August 2014 22:20 |
Need help: StormC 3 | AlfaRomeo | Coders. General | 27 | 10 October 2008 12:31 |
StormC V4 | Oneillsite | request.Apps | 4 | 06 October 2006 23:49 |
StormC V4 | FromWithin | Coders. General | 13 | 24 July 2005 17:20 |
|
|