|
Cowcatcher posted:I'm using fread in VC++ 9 to read a binary file, and it keeps returning me a bad pointer Do you allocate memory for your buffer somewhere in that ellipsis
|
# ? Jun 16, 2009 20:30 |
|
|
# ? May 15, 2024 11:49 |
|
Otto Skorzeny posted:Do you allocate memory for your buffer somewhere in that ellipsis yes, I used buffer = (char*)malloc(size); buffer is fine after allocating, I can read/write, but as soon as fread returns I can't touch it anymore or else it crashes
|
# ? Jun 16, 2009 20:37 |
|
What's errno immediately after all this
|
# ? Jun 16, 2009 20:45 |
|
You don't want the & before buffer in fread; it is causing you to overwrite the address of the buffer you allocated (and promptly overflow into the stack) instead of writing into the buffer you allocated.
|
# ? Jun 16, 2009 20:56 |
|
/\/\/\what he saidOtto Skorzeny posted:What's errno immediately after all this I just noticed I'm noobishly passing &buffer instead of buffer
|
# ? Jun 16, 2009 20:57 |
|
Cowcatcher posted:
|
# ? Jun 16, 2009 21:51 |
|
Lexical Unit posted:Doesn't fopen_s() return 0 on success? Yes. MSDN posted:Return Value
|
# ? Jun 16, 2009 22:36 |
|
I've been reading lately into compiler design and development, and most notably into compiling to bytecode that is later JIT compiled like .NET and Java do. Basically what I'm wondering is, what's the point of compiling to bytecode? Why not just store the syntax and program flow trees instead? You know, I'm thinking maybe build the trees out of the original source code, run some non platform-specific optimizations, and then store that. Then when the time comes to JIT, just reload the trees and generate machine code while doing some platform-specific optimizations. It just seems to retarded to have to compile to a stack machine, just to reverse it again to a register machine (and have to perform flow analysis all over again). The only advantage I see is that I guess the bytecode would be faster to interpret than a tree, but then perhaps you can just generate bytecode out of the trees if you must interpret it. Is there a reason I'm missing as to why it's not done this way?
|
# ? Jun 17, 2009 21:55 |
|
mantralord posted:Basically what I'm wondering is, what's the point of compiling to bytecode? Bytecode preserves memory locality during execution much better than abstract trees, which tends to be a worthwhile optimization for most interpreters. Furthermore, there is a preexisting large body of work on optimizing instruction-based compilers, which is very tempting to try to apply.
|
# ? Jun 17, 2009 22:13 |
|
There are four things to note here. The first is that Java bytecode was initially designed solely for interpretation (with a conjectured chance of direct hardware execution); they were not thinking about using bytecode as an IR for a native compiler. So in that case, at least, you're right that it's far from optimal for that purpose. The second is that interpretation (or analogously an initial "splat" native compile) is a very important execution mode for JITted languages. The bulk of the code in most programs is not executed enough to pay for an optimizing compilation. Anything imposing significant overhead on these initial executions would be very bad. The third is that the AST, even a binary version thereof, would not be a very good IR for a JIT. If you were designing something purely for last-mile platform-specific optimization and code generation, you would almost certainly want some abstract bytecode representation, probably in SSA form, possibly even with embedded live-ranges information. The fourth is that these JITs are never designed solely for last-mile optimization, because many of their most powerful optimizations are essentially whole-program optimizations that the language doesn't let you make in advance — you can only do them by detecting that, e.g., class X has no subclasses loaded.
|
# ? Jun 17, 2009 22:37 |
|
ShoulderDaemon posted:Bytecode preserves memory locality during execution much better than abstract trees, which tends to be a worthwhile optimization for most interpreters. Furthermore, there is a preexisting large body of work on optimizing instruction-based compilers, which is very tempting to try to apply. Yeah, thats why I figured directly executing an abstract tree would be slower than bytecode. However, I'm more interested in the final JIT compiled code. The biggest problem I see is having to convert a stack machine back to a flow control tree (so you can do machine-specific optimizations), which seems more difficult than the other way around. Actually I'm just talking out of my rear end here, maybe the bytecode approach would make sense if I actually tried to implement all these things, but it just seems like you're adding an extra unnecessary layer of abstraction between source code and machine code. Also I'm assuming here that bytecode is just another language that needs to have abstract trees created for it and all that jazz to be able to do a quality translation to machine code, instead of just directly translating it to machine code. I hear alot of C compilers actually generate bytecode internally instead of using the abstract trees directly...is this true?
|
# ? Jun 17, 2009 22:46 |
|
rjmccall posted:There are four things to note here. Yeah, you know, I basically just started researching this stuff like yesterday, in my mind I thought that you could do most compilation tasks with a flow of control tree of some sort. I guess I better look up this "SSA" stuff, it might provide some extra insight.
|
# ? Jun 17, 2009 22:50 |
|
mantralord posted:Yeah, you know, I basically just started researching this stuff like yesterday, in my mind I thought that you could do most compilation tasks with a flow of control tree of some sort. I guess I better look up this "SSA" stuff, it might provide some extra insight. Well, it all sortof depends on what kinds of optimizations you want to do — but yeah, it sounds like you've got a lot of reading ahead of you. Don't hesitate to post (maybe in your own thread) if you have more questions as you go.
|
# ? Jun 17, 2009 23:04 |
|
Stacks are also pretty easy to compile to as compared to register machines. Bytecode typically doesn't require as much effort to store as it is pretty linear. blso Bytecode is typically used for the ease of implementation, rather than efficiency. Aside: If you're looking into SSA I think there is an optimized graph colouring method for register allocation. aha: http://digbib.ubka.uni-karlsruhe.de/volltexte/documents/6532 tef fucked around with this message at 23:37 on Jun 17, 2009 |
# ? Jun 17, 2009 23:30 |
|
Can anyone recommend a good book on compiler design? I'm currently considering this one, based on absolutely nothing, so I better ask before I end up buying a piece of poo poo book. Keep in mind I already know programming quite well, so an advanced book that doesnt babby me around would be fine by me. You know, something like the K&R of compiler design.
|
# ? Jun 18, 2009 00:03 |
|
Aho, Sethi, and Ullman's book is generally considered to be a strong introductory and reference text.
|
# ? Jun 18, 2009 00:09 |
|
ShoulderDaemon posted:Aho, Sethi, and Ullman's book is generally considered to be a strong introductory and reference text. You may want to pair it with a text on language theory such as the Sipser or the Ullman / Hopcroft, as the Dragon book drops you in the deep end with respect to grammars and whatnot. It'd be fun to start up a reading group for the Dragon text. I really hope I get to TA the compiler class next year Dijkstracula fucked around with this message at 00:17 on Jun 18, 2009 |
# ? Jun 18, 2009 00:15 |
|
On the other hand, the appel books on implementing compilers might be a bit more accessible, but not as deep or thorough coverage.
|
# ? Jun 18, 2009 02:48 |
|
Dijkstracula posted:If you want the K&R of compiler design texts, this is the one. It doesn't gently caress around and is pretty intense. tef posted:On the other hand, the appel books on implementing compilers might be a bit more accessible, but not as deep or thorough coverage. I bought both of the aforementioned books for my compiler design class in college (the 1st ed. of the Dragon book and Appel's Modern Compiler Implementation in Java). tef and Dijkstracula provided dead-on descriptions. I loved both of them though, and they are currently sitting on my work bookshelf as I slave away tweaking our internal data query language
|
# ? Jun 18, 2009 03:54 |
|
does anyone remember that desktop interface we all made a few years back? It was called tsDesk or something? It was originally made by 69apples or someone.. I was asked to help with a project recently and if I can find out old work it would really help.
|
# ? Jun 18, 2009 05:43 |
|
rugbert posted:does anyone remember that desktop interface we all made a few years back? It was called tsDesk or something? It was originally made by 69apples or someone.. this? googling "tsdesk" seemed to help
|
# ? Jun 18, 2009 06:18 |
|
How fast is the FPU in modern CPU's? I wrote a bitmap scaling routine and it relies on floats. Speed is obviously nice, is there going to be a very worthwhile gain if I rewrite it for fixed point? edit: while I'm at it... _ftol is without a doubt slow, so I looked around and sure enough there is a conversion instruction. I figured I'd just do this code:
slovach fucked around with this message at 10:56 on Jun 19, 2009 |
# ? Jun 19, 2009 08:58 |
|
slovach posted:edit: while I'm at it... _ftol is without a doubt slow, so I looked around and sure enough there is a conversion instruction. http://software.intel.com/en-us/articles/fast-floating-point-to-integer-conversions/
|
# ? Jun 19, 2009 14:00 |
|
edit nevermind Cheesemaster200 fucked around with this message at 22:21 on Jun 19, 2009 |
# ? Jun 19, 2009 22:19 |
|
TSDK posted:If you're using VC++, just use the /QIfist switch and change the rounding mode at program start-up, as detailed here: This is certainly more elegant, thanks.
|
# ? Jun 19, 2009 23:40 |
|
defmacro posted:this? that page had a bunch of old broken links but I think I found a copy. I was looking for it for some help on a small project Im working on. How can I run programs located on a user's PC from a link in firefox?
|
# ? Jun 21, 2009 19:20 |
|
rugbert posted:I was looking for it for some help on a small project Im working on. How can I run programs located on a user's PC from a link in firefox? You'd probably need to use Chrome (the Firefox thing, not the Google browser) since that would be a security nightmare otherwise.
|
# ? Jun 21, 2009 21:32 |
|
Can someone tell me about using shared memory in Windows using C++? I need to set up a way for multiple programs to read from one device that is sending in a stream of data and shared memory seems to be the best way. I'd especially like to know about how to deal with the fact that programs need to be reading from it while it's being written to constantly. I am a newbie programmer so I am just not sure where to start.
|
# ? Jun 22, 2009 22:14 |
|
HondaCivet posted:Can someone tell me about using shared memory in Windows using C++? I need to set up a way for multiple programs to read from one device that is sending in a stream of data and shared memory seems to be the best way. I'd especially like to know about how to deal with the fact that programs need to be reading from it while it's being written to constantly. I am a newbie programmer so I am just not sure where to start. In Windows, shared memory is generally implemented as a memory-mapped file. Boost has a slightly more generic version that may be easier to use (it also has the benefit that if you ever need to switch to UNIX, you don't need to touch anything): http://www.boost.org/doc/libs/1_39_0/doc/html/interprocess/sharedmemorybetweenprocesses.html There are a bunch of utilities in Boost.Interprocess that might make this easier. (PS just get on AIM or whatever) Avenging Dentist fucked around with this message at 23:22 on Jun 22, 2009 |
# ? Jun 22, 2009 23:18 |
|
I've been wracking my brain about this, but my calculus skills aren't that sharp right now. I have a camera position, a camera target, and a gun all in 3D space. I want to link the positions of the camera position and target to the gun so when it's changed rotation the others follow. I've tried to avoid updating the positions directly when I rotate the gun, but rather use a global Update() method every time a new frame is drawn. So I have the gun's old rotation, and I have the new rotation. How do I update the positions here? I assume I have to use some nifty rotation matrix but I suck at that poo poo. I'm writing this in C# with that XNA Game Studio API if that makes a difference.
|
# ? Jun 22, 2009 23:33 |
|
Boz0r posted:I've been wracking my brain about this, but my calculus skills aren't that sharp right now. Not to poo poo on your parade, but if you're having trouble with this trivial problem, what all do you expect to accomplish with your awesome game?
|
# ? Jun 23, 2009 03:33 |
|
Ugg boots posted:Not to poo poo on your parade, but if you're having trouble with this trivial problem, what all do you expect to accomplish with your awesome game? Nothing specific. Just a learning experience.
|
# ? Jun 23, 2009 10:28 |
|
Boz0r posted:I've been wracking my brain about this, but my calculus skills aren't that sharp right now. What I do is just draw a simple diagram of what I want, then use basic high school maths to work out manually what the new positions and angles should be. Then I work out the general transitions and how to implement that in the program. In the end I usually just end up with the standard rotation matrices, etc, (maybe left handed instead of right handed), but I generally understand what's going on then. You may need to be careful looking at the ranges of certain trig functions and fix that as well. I'm not too sure exactly what you are asking. But I would translate everything so that the gun is at the origin. Then calculate the normal(or vector you want the camera to be from the gun) of the gun surface and using that and the distance of the camera and target to the gun, you can work out the point of the camera and target. Then translate the gun back to it's original position. This would basically make the gun look like it's static and not moving, whatever angle it's at.
|
# ? Jun 24, 2009 13:21 |
|
nm
nbv4 fucked around with this message at 03:07 on Jun 27, 2009 |
# ? Jun 26, 2009 00:12 |
|
Does this forum have a thread for WMI/VB scripters? I'm pretty new to WMI scripting and I'm trying to do stuff that I haven't been able to find out by googling and searching Microsoft TechNet
|
# ? Jun 26, 2009 01:37 |
|
Anyone know any quick painless ways of checking for corrupt/incomplete JPGs on windows? It seems theres a jpeginfo utility for unix but I'm not seeing anything simple like that for windows..
|
# ? Jun 27, 2009 12:52 |
|
aptitude tells me jpeginfo only depends on libc6 and libjpeg62 (which was written by 'The Independent JPEG Group' and itself only depends on libc6), is it portable to windows perhaps?
Blotto Skorzany fucked around with this message at 13:29 on Jun 27, 2009 |
# ? Jun 27, 2009 13:24 |
|
Otto Skorzeny posted:aptitude tells me jpeginfo only depends on libc6 and libjpeg62 (which itself only depends on libc6), is it portable to windows perhaps? I tried it out and it pops up a big stupid focus stealing dialog box Not exactly going to work nicely in a shell script. I'm starting to think I'm better of just doing this from linux, it just seems silly that theres currently no easy way to do this on windows.
|
# ? Jun 27, 2009 13:30 |
|
tripwire posted:I saw that another similar program was ported to Windows called jpegtran (for lossless rotation I guess). One of the results on google was someone saying that it also notifies you of a premature end of stream if you just feed it jpegs. You could probably do something with the windows imagemagick.
|
# ? Jun 27, 2009 13:35 |
|
|
# ? May 15, 2024 11:49 |
|
Scaevolus posted:You could probably do something with the windows imagemagick. Ugh. The first result on google is the site admin (of www.imagemagick.org) responding to this question with "To detect corrupt images you would need to write your own exception handling methods and intercept the messages as they are thrown." What the gently caress? No thanks edit: Hah, I misunderstood (serves me right for skimming that thread instead of reading the whole thing). I can just call identify --verbose for each image, then check for the presence of "Premature end of data segment" in the output. tripwire fucked around with this message at 13:45 on Jun 27, 2009 |
# ? Jun 27, 2009 13:38 |