| |
| |
| |
|
Page: 1 2 3 4 5 6 7 8 9
Comments:
<0> eg, 4-byte boundries. <1> it's a struct <1> and i am moving it futher into an array <0> well, the elements of the struct then. <1> by an arbitrary ammount <0> pretty much everything except for 'char' requires alignment <1> still, even if it needs to be aligned <0> so directly incrementing only by a byte is not valid, in general. so, you will need to do it the long way. <1> my struct is greater than sizeof(long) <0> yeah, but this is a very rare operation, and so it is not something you ordinarily need to do. <1> ok, so there is no other way apart from casting to char and back <1> in three c statements <0> correct <1> ok, that's a shame
<0> if you are directly working with memory, you should expect to work on char * <2> use a void * <0> pointer arithmetic is invalid on void* <0> char* is the proper base type for memory manipulation. <1> well i've actually managed to avoid char* until now <0> dila, but where did the buffer come from in the first place? <1> it's a heap <0> ah, well, yeah, it's expected that low-level memory operations, such as this one, will be using char * <1> hmm <1> but you see i have a struct that has the size of the bufer <1> and i'm moving the buffer further into the heap <0> off the end of the buffer? <1> so i don't actually need to use char* <1> never mind <1> the problem is with c syntax <1> the code is fine <0> hehe <1> oh well <1> that was the last line of my heap cl*** <1> which is the only part i am anoyed about <1> since it's three c statements for an operation that is a single ***embly instruction <1> IA32, anyway <0> most heap implementations work on char *, and only cast to struct (for bookkeeping info, etc) as necessary. <0> however, i still suspect you are ignoring alignment considerations, which will not work on many non-ia32 architectures. <0> you're free to ignore alignment on x86, but there is a performance penalty for it. <0> dwords, for eg, should be 4-byte aligned. <2> saying your chosen alignment is chaotic evil has no meaning here <1> well the new[] operator can enforce alignment if necessary <0> im not sure it can, but thats not what i was talking about.. i was talking about the alignment of the members of your bookkeeping struct. <0> and as far as i know, all returns from operator new need to have 'universal alignment' <1> yes <1> so if new[] rounds the size of the requested buffer to a four byte boundry it will guarentee that the bookkeeping structs are also aligned <0> ok, i guess. i don't really understand what you're doing. <1> it's just that the heap cl*** is capable of performing un-aligned allocs <1> but the heap cl*** isn't going to be the primary interface for memory allocation <1> the heap cl*** doesn't work anyway <1> i have descoveredd <1> which i guess you might find amusing :) <1> oh well, thanks for the help <3> gcc allows pointer arith on void*. This is nonstandard expention. <2> it is a bit bizzare too , because void is nothing so can't have a length <3> yeah <2> does it work the same as pointer arithmetic on a char * <3> yeas <0> http://www.college***advice.com/*********ion-mistakes.shtml <4> lol... <4> . <4> lol <3> AaronWL: did you sleep today ? <2> AaronWL, I like number 17 :) <5> Hi all. I appologize, I'm not a C++ guy but Im trying to use SWIG to generate a wrapper for a simple header file. Anyone done anything like this? <6> why not ask in #c++ ?
<7> pwnd <5> Because it said help questions should be directed here <6> because they're lying ****s <5> Those bastards :) <8> haha <8> he asked in #C++ <8> let me just tell him to ask in #C... <5> I'm more then willing to just pay someone to do this, if anyone is interested. <7> lol <7> how much? <7> $120 an hr <5> Take a look at the header file and let me know what you think it's worth. <7> 3hr minimum <5> And that would be more then its worth. <7> sorry, my time is valuable <5> Im sure, but this project isnt :) <7> ask a n00b then <6> If I knew wtf you were talking about it'd do it for $50 <5> zid_: http://rafb.net/paste/results/ZT6YWG92.html <5> Thats the header file. I need the functions defined by that file to be accessible to either .NET or Java. <5> doh :( <5> And I know .NET and Java, but no C++ :) Certainly not enough to do this simple task. <6> what's the problem anyway, aren't the names getting mangled how .net wants them? <9> Java can call functions with C binding but not C++ binding as far as I know. <5> Its the use of callbacks, hwnds and structs that are screwing me up. <6> oh so everything exports ok? <5> I can hack together this type of thing with simple code, but all the custom crap in that header file is killing me because I dont know C++ <5> java can natively call C++ <9> You could, of course, write C functions wrappers for the C++ functions. Then, Java could call the C functions. <9> It can? That's news to me. <5> yeah, let me find the link on Sun's site. <10> java can call "native functions" <5> This will do: <5> http://www.javaworld.com/javaworld/javatips/jw-javatip17.html <11> how can i return a char array from a function? <10> zerocide: you must either malloc a char array that you return a pointer to or the preferred method would be to p*** a pointer to an array to the function that the function would fill <11> ah <11> yeah, i did the 'preferred' method <11> was just curious about actually returning it <11> thanks :) <10> a more-creative method would be to create a struct that contains an array and then return the struct <6> OrngeTide? <11> oh <11> that sounds nice <12> Returning the struct is very inefficient, return or p*** a pointer <10> Maloeran: it's all relative ;-) most c++ programmers use a lot of inefficient copies <11> why is it inefficient? <11> does it return a copy of the struct? <10> yes <11> oh, heh <11> but it is possible to return a pointer to it <11> isn't it? <10> you can't return a pointer to a local variable/struct/array. you'd have to malloc the struct <12> If it was malloc'ed, sure, or make the calling function hands a pointer to the struct <10> which you're not gaining anything over using an array <11> oh <11> oh yeah, i can see why <13> Arses <14> (: hi <13> ****er <13> I mean erm, hi <15> hi
Return to
#c or Go to some related
logs:
disable connection tab suna thermometer #stocks #hardware #vmware hardware-ram-tester hooking Createprocess donkey dink #sex #firebird
|
|