|
People use SDL2 routinely on x86_64, it works fine. Are you using the cmake build properly? You can probably scrounge prebuilt binaries if you need to, but the build should work fine. Whatever you do don't use mingw, it is bad. One of the best things about Rust for game purposes is first-class Windows (i.e. MSVC) support.
|
# ? Feb 6, 2018 08:19 |
|
|
# ? May 10, 2024 03:13 |
|
SDL2 gfx is not a part of official SDL.
|
# ? Feb 6, 2018 12:09 |
|
Well that's confusing. Maybe try using a non-dead library instead.
|
# ? Feb 7, 2018 04:15 |
|
Sorry, just got around to this. The library builds on MSVC x64 with MMX disabled. I wasn't able to confirm that functionality is as expected but I don't see any reason to doubt it. Thanks for the advice, folks. edit: Yep tried it out after I got home from work and it's perfect. Fergus Mac Roich fucked around with this message at 03:19 on Feb 8, 2018 |
# ? Feb 7, 2018 17:17 |
|
I have a bit of a weird question that was inspired by Raymond Chen's latest blog entry.quote:The initial implementation of the Bit¬Blt function in 16-bit Windows didn't have any special tricks. It was static code that supported the sixteen raster operations that involve a source and destination. ... generating code on the stack, on the fly? I'm not sure how that works. Can you really do something like code:
Thanks a bunch, apologies if this is dumb.
|
# ? Feb 9, 2018 19:59 |
|
Colonel J posted:I have a bit of a weird question that was inspired by Raymond Chen's latest blog entry. Yep, pretty much, except on modern operating systems/processors, you generally can't generate code onto your stack anymore because it's marked no-execute. Nowadays, you have to separately allocate executable pages of memory to generate code into.
|
# ? Feb 9, 2018 20:04 |
|
You can disable the NX bit on a per-binary basis if you want - it's not set in stone. There are actually some cases where you can get GCC to push some code on the stack if you're clever enough.
|
# ? Feb 9, 2018 20:07 |
|
See this: https://stackoverflow.com/questions/8179521/implementation-of-nested-functions
|
# ? Feb 9, 2018 20:11 |
|
Huh that's kind of blowing my mind, thanks for your answers. There's always something more to amaze me. "allocate executable pages of memory" was the keywords I needed, and this stack overflow question shows how to do it in modern C++.
|
# ? Feb 9, 2018 20:17 |
|
Colonel J posted:Somehow move the instruction pointer there and just feed those bytes to the processor? The 'somehow' is just creating a function pointer and setting it to that address then calling it (then your machine code - not asm - follows the appropriate calling convention), yeah.
|
# ? Feb 9, 2018 20:57 |
|
Colonel J posted:Huh that's kind of blowing my mind, thanks for your answers. There's always something more to amaze me. https://www.youtube.com/watch?v=cw5a5I8OoY0 Slides are here: http://www.cs.cmu.edu/afs/cs/academic/class/15213-f17/www/lectures/09-machine-advanced.pdf When I took this class, one of the assignments was to actually implement some of these techniques and it was pretty drat cool.
|
# ? Feb 9, 2018 21:41 |
|
Star War Sex Parrot posted:If you want to learn more, here's a lecture (from an intro to computer systems class) that covers things like buffer overflows, stack smashing, and return-oriented programming attacks in C. It also talks a bit about things like NX bit, stack canaries, and other mitigation techniques.
|
# ? Feb 9, 2018 21:43 |
|
Jeffrey of YOSPOS posted:Did you explode your bomb lab???? Jeffrey of YOSPOS posted:I did once, shameful. Jeffrey of YOSPOS posted:Always cool to see CMU goons around.
|
# ? Feb 9, 2018 21:49 |
|
Colonel J posted:Can you really do something like
|
# ? Feb 9, 2018 23:34 |
|
I have to get a C++ project from 2011 to build, and I'm having a hell of a time. I'd like to be able to just get a working binary out with as little fuss as possible, but right at the entry point in global scope it starts with code:
Long story short, I've got a ton of ambiguous references, and I'm not even sure where to start. Just remove all "using" statements and be specific about namespace where things are called?
|
# ? Feb 10, 2018 21:33 |
|
Twerk from Home posted:I have to get a C++ project from 2011 to build, and I'm having a hell of a time. I'd like to be able to just get a working binary out with as little fuss as possible, but right at the entry point in global scope it starts with It's more that since then a lot of boost stuff emigrated to std. I think shared_ptr, unique_ptr, etc, started in boost. So just be specific; I think it might be easier for you to start by removing "using namespace boost", adding "boost::" to the names that aren't found, then maybe doing the same with "using::std", if you're not one of those freaks who is okay with that.
|
# ? Feb 10, 2018 21:40 |
|
Absurd Alhazred posted:It's more that since then a lot of boost stuff emigrated to std. I think shared_ptr, unique_ptr, etc, started in boost. So just be specific; I think it might be easier for you to start by removing "using namespace boost", adding "boost::" to the names that aren't found, then maybe doing the same with "using::std", if you're not one of those freaks who is okay with that. That's where I was starting. It looks like I might just need to update boost as well, because even after starting down that path, I'm still getting ambiguous pair from trying to include just a single boost class: "include/boost/functional/hash/extensions.hpp:34:33: error: reference to 'pair' is ambiguous" looks a hell of a lot like: https://marc.info/?l=boost-bugs&m=132481728414582&w=2 and that issue was fixed about 6 years ago: https://svn.boost.org/trac10/ticket/6323 OK. Updating boost it is!
|
# ? Feb 10, 2018 21:54 |
|
Twerk from Home posted:That's where I was starting. It looks like I might just need to update boost as well, because even after starting down that path, I'm still getting ambiguous pair from trying to include just a single boost class: "include/boost/functional/hash/extensions.hpp:34:33: error: reference to 'pair' is ambiguous" looks a hell of a lot like: https://marc.info/?l=boost-bugs&m=132481728414582&w=2 and that issue was fixed about 6 years ago: https://svn.boost.org/trac10/ticket/6323 That's usually a good idea anyway.
|
# ? Feb 10, 2018 21:54 |
|
Twerk from Home posted:
lol, you must be working at my job Anyway you'll need to go through every library call to disambiguate between Boost calls and stdlib calls. The interface for most of them is the same if the Boost libraries were ported to standard so it's not too difficult, just tedious.
|
# ? Feb 10, 2018 21:58 |
|
Absurd Alhazred posted:That's usually a good idea anyway. Not if the original boost library included with the code was customized! I guess I'm just hosed, because it was using a custom boost that had subgraph::remove_vertex implemented. I've been looking through old boost versions to figure out what version was originally included, and that function shows up in 1.34, was commented out in 1.45 right here, and was never anything but an assert(false) in between. Either this is a boost that was pulled from the trunk during one hot minute when that was implemented and then undone before a version release, this is from some branch of boost that never merged to master, or the original developers of this application modified boost. Does this look familiar to anyone? This is the included boost subgraph.hpp, that doesn't match any released version of boost that I can find: code:
Here's some discussion about why subgraph::remove vertex is marked wontfix: https://svn.boost.org/trac10/ticket/4752. I guess I don't really have a question anymore, but I wanted to vent about this insanity. Twerk from Home fucked around with this message at 06:12 on Feb 11, 2018 |
# ? Feb 11, 2018 06:01 |
|
Twerk from Home posted:Here's some discussion about why subgraph::remove vertex is marked wontfix: https://svn.boost.org/trac10/ticket/4752. I guess I don't really have a question anymore, but I wanted to vent about this insanity. Wow, that's really counter-intuitive for me. Their argument is really specific to their implementation of graphs, but all of my encounters with boost libraries have had them try and be as specifics-agnostic as humanly possible.
|
# ? Feb 11, 2018 06:11 |
|
I’m doing stuff with a shared memory segment holding a C++ object or struct. After reading the strict aliasing stuff on the last few pages I’m wondering if there’s anything I wasn’t thinking about that I should be. On the create side I placement new the type into the memory segment after it’s set up then use it with the resulting pointer (I know the destructor needs to be called manually). On the connect side I static_cast the void * to the object type T *. As I understand it, the connect side behavior breaks the strict aliasing rules. Is this correct? Would that even matter since the contents of the void * can’t even be accessed so the situation where the optimizer might break the code due to accesses from both pointer types should never happen?
|
# ? Feb 11, 2018 16:16 |
Probably make sure any data members are protected with synchronization. I think this is a situation where you should use 'volatile'.
|
|
# ? Feb 11, 2018 17:54 |
|
void* can alias anything and volatile doesn’t do any synchronization
|
# ? Feb 11, 2018 18:20 |
pseudorandom name posted:void* can alias anything and volatile doesn’t do any synchronization I didn't mean to use volatile for synchronization, but rather to inhibit optimizations, where the compiler might assume that a value written to a field stays the same later in the flow.
|
|
# ? Feb 11, 2018 18:31 |
|
I have higher level synchronization with semaphores. The semaphores are used to pass the segment from one program to the other, and logical access to the segment is guarded inside a moveable type so no one *should* access it when they don’t have ownership (though they could save off a pointer if they were determined to mess things up). I don’t think volatile is necessary in this case since when one program wants to use the object inside the segment they have to get the pointer again rather than having kept it around such that the compiler might think it’s old.pseudorandom name posted:void* can alias anything and volatile doesnt do any synchronization I thought void * being able to alias anything means that code:
|
# ? Feb 11, 2018 20:04 |
|
Dren posted:I thought void * being able to alias anything means that No error there assuming Something is the real type of something. e: also assuming Something isn't a function type...
|
# ? Feb 11, 2018 20:08 |
|
eth0.n posted:No error there assuming Something is the real type of something. Yep, it’s the real type and not a function type. Thanks.
|
# ? Feb 11, 2018 20:12 |
|
Yeah, strict aliasing is all about accessing objects using the wrong type for the actual object. If you’re placement-new’ing an object into memory and then accessing it as that same type, you’re fine; it doesn’t matter what intermediate types you might have had pointers to if you never actually accessed the memory. void* is not special.
|
# ? Feb 11, 2018 20:27 |
|
Hi I'm a new programmer and an idiot. I swear I'm not asking you to do my homework. My program does everything it is supposed to do except for this hitch here that I'm a bit puzzled about. It's an assignment to make a special class to handle really, really big numbers (Googling around shows me it's a fairly common assignment). My overloaded division isn't working right.code:
I'm a few semesters in and this seems like a total intro to programming problem and I should know better. What's my error?
|
# ? Feb 11, 2018 22:59 |
|
The algorithm seems right. Within your function you invoke HugeInteger’s copy constructor, operator>=, operator=, operator-, and construction from an initializer list. Perhaps there is an error in one of them. Test each one individually. There are many practices you can adopt if you want to be sure of the correctness of your program. Expects and Ensures check preconditions and postconditions of methods (you can just use asserts if you don’t feel like pulling in the gsl). Unit test frameworks provide niceties to help hammer your methods with edge cases and find exactly where they fail. Lastly, you could learn to use the debugger instead of debugging with print statements. All of these things involve extra up front effort but if you employ them to check your assumptions they will prevent a great many head scratcher bugs like this one.
|
# ? Feb 11, 2018 23:33 |
|
Curious as to what's going on here:C++ code:
|
# ? Feb 12, 2018 00:54 |
|
Harik posted:Curious as to what's going on here: Why not just pass it by reference? It's only used within the lifetime of your main, anyway.
|
# ? Feb 12, 2018 01:01 |
|
Dren posted:The algorithm seems right. Within your function you invoke HugeInteger’s copy constructor, operator>=, operator=, operator-, and construction from an initializer list. Perhaps there is an error in one of them. Test each one individually. You are wise. My operator>= was screwy.
|
# ? Feb 12, 2018 01:37 |
|
Absurd Alhazred posted:Why not just pass it by reference? It's only used within the lifetime of your main, anyway. Because this is clearly a toy example and the actual usecase is avoiding doing disk IO loading the .wav file in the audio thread? Normally, all the audio is loaded at startup, but I had to add new samples at runtime, so I made the "obvious" change to do the work on the calling thread: C++ code:
G++7 and clang-5. E: I can't put a mutex around sample_map because that puts the lock in the hotpath of feeding audio. By just doing the assignment the workqueue can be run as soon as the audio buffers are filled. code:
Harik fucked around with this message at 02:12 on Feb 12, 2018 |
# ? Feb 12, 2018 02:06 |
|
Harik posted:Because this is clearly a toy example and the actual usecase is avoiding doing disk IO loading the .wav file in the audio thread? Normally, all the audio is loaded at startup, but I had to add new samples at runtime, so I made the "obvious" change to do the work on the calling thread: Are you sure your problem isn't that you're naming what you're moving to the same as what you're moving from? What happens if you use this: C++ code:
C++ code:
|
# ? Feb 12, 2018 02:12 |
|
Harik posted:This should work in C++14, but it explodes when I try to do it. It makes sense, since you can't copy around a unique pointer and std::function is copyable. So, given this is explicitly supposed to be possible per the C++14 FAQ, how should it be done? unique_ptr is move-only so a lambda that captures it is also move-only, and std::function can only hold copyable callables. The rationale for that is that the very type erasure you're using std::function for also means it can't just disable copy constructors/operators at compile time if it's constructed from a move-only type. That type information only exists within the constructor. It could set some flag during construction that would make it throw an exception if you tried to copy a std::function after filling it with a move-only type, but that's a design choice and the language committee decided against it. I guess it's just nicer to know you can always copy a std::function. The FAQ you linked is talking about a situation more like: C++ code:
EDIT: As for the details you gave about your real use-case: you're just going to have give up on capturing a unique_ptr. The generally accepted next-best-solution is to just use shared_ptr. Lime fucked around with this message at 02:29 on Feb 12, 2018 |
# ? Feb 12, 2018 02:17 |
|
Harik posted:This should work in C++14, but it explodes when I try to do it. It makes sense, since you can't copy around a unique pointer and std::function is copyable. So, given this is explicitly supposed to be possible per the C++14 FAQ, how should it be done? Downgrade the unique pointer to a shared pointer; or, if you absolutely need a unique pointer, store a shared pointer to a unique pointer It's the unfortunate reality of std::function, don't fight it. Yes, other frameworks have universal function pointers that do support move-only functors, but not the standard library e: Hell, I think I may have worked around it by writing an utility routine that makes move-only functors copyable by moving them to the heap, making a shared pointer to the moved functor, capturing the shared pointer in a lambda that forwards calls to the moved functor, and returning the lambda. Pretty gross but at least it keeps the rest of the code clean hackbunny fucked around with this message at 02:32 on Feb 12, 2018 |
# ? Feb 12, 2018 02:25 |
|
SuperKlaus posted:
Fwiw I think you have another error besides the one stated. Hint below if you want it. It's another case where you are going to return too small a value.
|
# ? Feb 12, 2018 02:31 |
|
|
# ? May 10, 2024 03:13 |
|
Thanks, everyone. I thought it was a problem with run(), but the limits of capturing unique_ptr make more sense now. Funny, given that I use unique_ptr and cross-thread runqueues everywhere but I've managed to never run into this until now. There's a landmine with my edited solution (allocate with new outside, pass the raw pointer, put into a unique_ptr inside the lambda.) If something changes and the lambda gets called twice it will wrap the "unique" pointer twice, and since the name is the same it will destroy the Sample right before it assigns the map the pointer to now-dead memory. I don't know why I'd change the workqueue to possibly run more than once, but it's still a landmine. Worst case before was eating the disk IO twice, which would be cached the second time anyway. Ended up making a second queue of (name, unique_ptr<Sample>) and importing everything from that where I have the runqueue(). The locking is trivial and I shouldn't ever be doing more than one sample update per frame, so my worst case cost is something like: code:
|
# ? Feb 12, 2018 03:18 |