|
Talk to me | CommitStrip[^]
I hate it when that happens!
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
That's the Schroedinger error.
|
|
|
|
|
Or a log flood that consumes all available resources.
|
|
|
|
|
The dread heisenbug strikes again!
Freedom is the freedom to say that two plus two make four. If that is granted, all else follows.
-- 6079 Smith W.
|
|
|
|
|
Daniel Pfeffer wrote: The dread heisenbug strikes again!
are you sure? I have some uncertainty (in principle)
|
|
|
|
|
This is like problems that only happens in release mode - but work perfectly fine in debug mode.
But then, there's entire articles dedicated to this topic...
|
|
|
|
|
dandy72 wrote: But then, there's entire articles dedicated to this topic...
Which can be boiled down to "your 'uninitialized' variables are getting initialized to different values in debug than release"
Real programmers use butterflies
|
|
|
|
|
Nowadays, sure.
I wasn't clear with my intent, but I meant there's numerous articles discussing how to debug release-mode apps, not why apps might behave differently.
|
|
|
|
|
I have the basis for what might be an interesting article in and of itself within my MIDI library.
There's a very tricky call i have to make that relies on passing essentially variable length structs, and consequently, the .NET marshaller cannot handle it out of the box. Instead of using StructLayoutAttribute and MarshalAsAttribute to mark up your structure and p/invoke function calls, you basically need to use StructLayoutAttribute and then use the Marshal class methods to copy the variable length portion in manually.
I don't know how many people have run into P/Invoking into C style libraries that take variable length structs, so is anyone interested in this?
I'd rather put this out there up front before I spend time and effort on an article that nobody cares about, and this is kind of arcana.
Edit: Big thanks folks. Your responses let me know there was some interest and I'm in the process of writing it.
Real programmers use butterflies
modified 4-Jul-20 7:37am.
|
|
|
|
|
As you and I have discussed, I think it would be worthwhile .. sure, I can pull apart your code and but that won't necessarily make it obvious
This will become another resource, along with Luc Pattyn's Article: P/Invoke, part 1 and to a much lesser extent pinvoke.net: the interop wiki!
My biggest achievement along the same lines I can't show in code, a) because it was commercial - wrapping a c++ PGP library and creating a C# layer for it, b) iirc it was relatively 'simple' structs etc
|
|
|
|
|
|
|
I'd read it
|
|
|
|
|
I posted it here: P/Invoke Jujitsu: Passing Variable Length Structs[^]
I hope you enjoy it.
I've been doing p/invoke so long and C coding before that that I kind of forget what people don't know when it comes to it. I didn't want to recover beginner P/Invoke stuff but let me know if I didn't explain something very well, when you get a chance to look at it.
Real programmers use butterflies
|
|
|
|
|
honey the codewitch wrote:
I was just teasing earlier, I'd have never made you type that much. What kind of monster do you take me for?
I was thinking about MarshalAs while reading about the MIDIHDR structure definition. Actually lol'd when I got to this part
I thought the article was really interesting. I've done p/invoke and marshalling stuff before but I learned quite a bit here. I had no idea about the StringBuilder trick for example I really enjoyed it!
|
|
|
|
|
That's good to hear. I'm glad you enjoyed it.
And thank you!
Real programmers use butterflies
modified 4-Jul-20 21:13pm.
|
|
|
|
|
I'd certainly read it
"We can't stop here - this is bat country" - Hunter S Thompson - RIP
|
|
|
|
|
P/Invoke Jujitsu: Passing Variable Length Structs[^]
Here you go. If I didn't explain something regarding how to do this technique very well, let me know and I'll append the article. I've been doing P/Invoke so long I may take for granted things people don't know.
Real programmers use butterflies
|
|
|
|
|
Just read it - very cool stuff going on in there - I love this kind of lowish level tech - well done
"We can't stop here - this is bat country" - Hunter S Thompson - RIP
|
|
|
|
|
pkfox wrote: I love this kind of lowish level tech
back in my day (1986 or so) that was called programming.
Seriously though, I'm always glad to know when someone appreciates one of my articles. thanks
Real programmers use butterflies
|
|
|
|
|
I have read it, but another thing is to understand everything
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
Rating helpful answers is nice, but saying thanks can be even nicer.
|
|
|
|
|
I welcome questions. I really wish it was something i could demonstrate with puppets.
Real programmers use butterflies
|
|
|
|
|
honey the codewitch wrote: I welcome questions Good to know
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
Rating helpful answers is nice, but saying thanks can be even nicer.
|
|
|
|
|
I have a background in bit twiddling on 8 bit and 16 bit machines in asm and later C so when I see a struct I automatically visualize its layout in memory. It makes doing p/invoke easy but hard to explain because i take things for granted that other people maybe struggle with.
I think it hurts my writing. So I'm serious, when you get a chance, if the way I'm writing and presenting this material makes it difficult for you or other readers to understand it, you are the most helpful resource around to me and I'd love your help in helping me explain it better, if that makes sense.
And if you're not interested or you don't have time that's okay too.
Real programmers use butterflies
modified 4-Jul-20 18:24pm.
|
|
|
|
|
Have you seen the second sentence of my signature?
I know what you mean.
I'll re-read it and give you a feedback, but it might get some time.
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
Rating helpful answers is nice, but saying thanks can be even nicer.
|
|
|
|