I [can't touch this](http://forum.nim-lang.org///copyfree.org/) because [it's
GPLv3](https://github.com/johnscillieri/netwatch/blob/master/LICENSE.txt)... 8~(
MacOS would be nice. I could test it if you need a tester. I have multiple
systems, wlans & routers & powerline devices in the network.
@Araq
Oh sorry, you are right, it was the other way around, because f0 and f1 are
identical, you can dereference a function pointer arbitrarily often. Every time
you dereference the pointer, the function is again equivalent to the pointer to
it.
I fail to see what the "all" should be? If I add 4 random memory addresses I
just get a meaningless value. But thats probably the error you talk about.
You need to add the size of the type the `pointer` points at. Thats the reason
you can't create an "+" like function without more information. A
I finally got around to releasing a small network utility called netwatch:
[https://github.com/johnscillieri/netwatch](https://github.com/johnscillieri/netwatch)
netwatch scans your network for hosts, lets you label them, and shows you the
last time they were seen:
Scanning 192.168
You must not using signed integers in pointer arithmetic, just because memory
address can't be negative and can be higher, then **0x8000_** for 32 bit
platforms and **0x8000___** for 64 bit platforms. So
var newp = cast[pointer](cast[uint](oldp) + 1u)
var abc*: xxx #wrong, should be proc abc(yyy: int): cint
No, that is a correct translation.
proc zzz*(f: ptr xxx) #wrong
I don't know about this. I suppose the typedef is "ignored" as an abstraction
and it really means "single pointer to function", not a "pointer to
this what i came up with for the + operator
proc `+`(a:pointer,p:pointer): pointer =
result = cast[pointer](cast[int](a) + 1 * sizeof(p))
I believe a person has to times the sizeof p by 1. But i could make it use
generics too i guess but i dunno.
And thank you filwit for
The c2nim translation posted by jlp765 is correct. But i found something wrong
when c2nim try to translate the _usage_ of the typedefed type. Sorry not to
mention them earlier.
typedef int xxx(int yyy);
xxx abc;
void zzz(xxx* f);
void www(xxx f);
zzz and
The `pointer` type doesn't have a `+` proc out-of-the-box (to prevent common
pointer arithmetic mistakes, iirc). So you need to cast each pointer to an int,
do the arithmetic on those, then cast the result back into a pointer.
Off the top of my head..
all = cast[pointer](
ca
I am still relatively new to doing this even in c, because i was used to using
vector in c++.
But since i am learning nim i don't know the way to correctly put a pointer
into a pre allocated pointer using cast in nim.
So here is what i'm working on.
import ../obj_parser, streams
11 matches
Mail list logo