Home > Archive > AWK > June 2004 > TAWK problem - anyone still using TAWK under Win32?
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
TAWK problem - anyone still using TAWK under Win32?
|
|
| Kenny McCormack 2004-06-25, 7:20 pm |
| Since there seems to be some interest (and interested parties) still
hanging around in regards to TAWK, here's something I was trying to get
working today. This works fine under Unix (Solaris), but I can't get it to
work under Win32 (Win98):
#!/path/to/tawk -f
# vim:fo-=t fo+=ro1
# Note: long is proxy for "FILE *"
extern dll "msvcrt.dll" long freopen(char *,char *,long)
BEGIN {
print "This goes to screen..."
freopen(fn = "tmp_test.fru","w",stdout)
print "This goes to the file ("fn")..."
}
Under Unix, the dll clause is not used, of course, and it works fine. Under
Win32, it fails with a GPF - which shows that it is finding the function, but
there is something wrong with the call convention. I tried the other calling
conventions (stdcall, winapi), as well as some things with the "name"
clause, but no joy.
Any ideas?
Note: I *have* gotten some things to work with this sort of syntax (and
using msvcrt.dll).
| |
| Jean-Marc QUERE 2004-06-26, 3:57 am |
| Dans son message précédent, Kenny McCormack a écrit :
try :
extern dll "msvcrt.dll" cdecl long freopen(char *,char *,long)
I use dll build with Delphi like :
myprojetct.dpr (delphi project) :
library myproject;
uses
SysUtils,
Classes,
...
const
...
var
...
function myfunction(...): integer; cdecl; export;
....
test.awk (tawk source) :
extern dll "myproject.dll" cdecl int myfunction(...)
....
--
APIEND informatique [R&D]
Site : http://www.apiend.com
| |
| Kenny McCormack 2004-06-26, 8:55 pm |
| In article <mn.d2247d465703ace9.8084@apiend.com>,
Jean-Marc QUERE <[nospam]quere.jmarc@apiend.com> wrote:
>Dans son message précédent, Kenny McCormack a écrit :
>try :
>extern dll "msvcrt.dll" cdecl long freopen(char *,char *,long)
Tried it - doesn't work. Note that cdecl is the default, but I did try
specifiying it explicitly as well.
>I use dll build with Delphi like :
>
>myprojetct.dpr (delphi project) :
>library myproject;
Interesting. I'd like to clarify a few things:
1) You do know what freopen() is, don't you? It is
a system/built-in function, not something I wrote myself.
2) I have to say that the main usefullness of TAWK's "DLL interface
capability" is not the ability to allow me to write my own code in
C/Delphi/whatever and use that in connection with AWK. Rather, it is the
ability to call the standard system functions directly, as if I were
writing in C. I.e., it removes the requirement to include all of the
C standard library as built-in AWK functions. I like TAWK in particular
because you can call them directly, with very little extra fanfare - unlike
in GAWK, where the interface is such that you always have to write and
compile your own little bit of code in order to get to the system functions.
The only time I would want to use a non-trivial external code base if
I want to access a library already written in a 3GL.
3) I could probably whip up a DLL in C, that would interface TAWK
to freopen(), in a half hour or so, but it ought not be necessary. It
should be possible to call freopen() directly, in Win32 (as it is in Unix).
I think somebody just needs to try a few more things, and figure out what
works.
| |
| Patrick TJ McPhee 2004-06-27, 3:55 am |
| In article <cbia29$l8j$1@yin.interaccess.com>,
Kenny McCormack <gazelle@interaccess.com> wrote:
% extern dll "msvcrt.dll" long freopen(char *,char *,long)
[...]
% Any ideas?
Is tawk itself linked against msvcrt.dll? If not, there could be
compatibility issues between the FILE * used by tawk's C library
and the system library. This would be especially true if tawk were
compiled with a non-ms compiler.
--
Patrick TJ McPhee
East York Canada
ptjm@interlog.com
| |
| Kenny McCormack 2004-06-27, 3:55 am |
| In article <cblect$qij$2@news.eusc.inter.net>,
Patrick TJ McPhee <ptjm@interlog.com> wrote:
>In article <cbia29$l8j$1@yin.interaccess.com>,
>Kenny McCormack <gazelle@interaccess.com> wrote:
>
>% extern dll "msvcrt.dll" long freopen(char *,char *,long)
>
>[...]
>
>% Any ideas?
>
>Is tawk itself linked against msvcrt.dll? If not, there could be
>compatibility issues between the FILE * used by tawk's C library
>and the system library. This would be especially true if tawk were
>compiled with a non-ms compiler.
TAWK is compiled with MS. (I knew this, but I just double checked, by
opening AWKW.EXE up in an editor and searching for and finding "Microsoft
Visual C++ Runtime Library" - which I think actually does mean that it was
linked against msvcrt.dll)
I don't know if it is linked against msvcrt.
How would I check? (Obviously, MS is not my preferred platform)
But note that TAWK was originally developed under DOS, then ported to Unix.
It is supposed to work, using a long as a FILE *.
The following example is given in the book:
# Second argument is actually a FILE*
extern fputs(char *,long)
BEGIN { fputs("hello, world\n",stdout) }
Still, thanks for responding - any other ideas?
| |
| Harlan Grove 2004-06-27, 3:55 am |
| "Kenny McCormack" <gazelle@yin.interaccess.com> wrote...
....
>I don't know if it is linked against msvcrt.
>How would I check? . . .
If you're using an NT-derived version of Windows (NT, 2000, XP, but not 95,
98, Me), you could select the file in Windows Explorer, 'right click' with
your mouse, and select Quick View from the pop-up menu. It'll show
references to other .DLL and .EXE files.
|
|
|
|
|