|
Google test is decent and usable. There's a bunch of interesting-looking C++11/14 libs on github that I haven't yet tinkered with as well, which promise to be much less macro-heavy and perhaps more actively maintained.
|
# ¿ Oct 23, 2015 02:30 |
|
|
# ¿ May 17, 2024 10:03 |
|
Qt is kind of worryingly heavyweight but it works pretty well and is easy enough to use in general. No idea what specific quirks there might be on windows, let alone when trying to use VS.
|
# ¿ Nov 7, 2015 08:11 |
|
Xarn posted:What is a nice and sane C++ concurrency library? This means higher level than <thread>, <mutex> et al. and less macroy than OpenMP pragmas. Joda posted:Why would I be getting an internal compiler error on a piece of code I've compiled with the exact same compiler hundreds of times before? I'm using g++ 4.9.something on MinGW64. On my current project I'm suddenly getting errors on an include of <vector> that seems to refer me to their implementation of initialiser lists.
|
# ¿ Nov 9, 2015 17:40 |
|
Build system chat: I ultimately just gave up and hand-rolled a python script to produce ninja files. Maybe Bazel will become good someday. Tup's pretty neat in a gimmicky kind of way, but it relies heavily on magic and is basically just one guy and he makes some weird design decisions.
|
# ¿ Nov 10, 2015 02:50 |
|
It doesn't play well with dependencies from the host system (because you can't sanely call pkg-config or similar) and as far as I can tell it's not realistic to vendor all your dependencies the way Google does with Blaze (because they'll have non-Bazel build systems and you really don't want to maintain your own build system of third party code). This leaves you with a build system that's only useful for projects without significant dependencies, and for projects without significant dependencies you can probably get away with a simple shell script anyway. It's also really awkward to use anything but the exact toolchain configuration that some engineer at Google assumed everybody would always want, because it relies on these great big sparsely-documented toolchain definition files. For example, I like to use clang 3.7 with libc++ on linux, but by default Bazel will have none of that. In general, doing anything off the beaten path (say, calling out to custom tools) rapidly lands you in territory with little if any documentation. Note also that the beaten path is almost entirely Java-related. My understanding is that they're working on fixing the first issue, at least, so maybe someday it'll be the cmake killer we all want, but it's not there yet and Google might just decide to abandon the effort before it gets close. Even ignoring all those issues, though, it's still a huge enterprisey java project with bad startup times and tons of its own dependencies and so forth. Not really what I want in a fundamental build tool. Ralith fucked around with this message at 09:13 on Nov 10, 2015 |
# ¿ Nov 10, 2015 09:10 |
|
It's worth noting that completely controlling the build environment is generally a great idea, especially for larger projects. It's just that right now, say, Nix (or even just a pile of shell scripts) does a better job of that than Bazel for anyone who isn't Google.
|
# ¿ Nov 10, 2015 20:07 |
|
What CPUs are you testing on?
|
# ¿ Nov 10, 2015 20:19 |
|
JawKnee posted:my local machine is:
|
# ¿ Nov 10, 2015 20:40 |
|
Plorkyeran posted:For purely internal software, absolutely. For anything intended to be built and run by third parties on their machines it's not really an option.
|
# ¿ Nov 11, 2015 02:32 |
|
Instead of returning a bool and taking a reference argument, return a std::optional<int> or whatever.
|
# ¿ Nov 20, 2015 02:37 |
|
OneEightHundred posted:If you like C# idioms then you're going to want to strangle someone when you find out what happens when you try to read a value from an STL map by indexing it with a non-existent key. Good rule of thumb for standard C++ and major libraries in general: If something seems obviously missing, it's probably there under another name, and you should go check the documentation to find out what that name is.
|
# ¿ Nov 20, 2015 02:58 |
|
sarehu posted:Don't use non-const references. (Except where you're supposed to.) sarehu posted:Edit: Also, even for reasonable complex types, the default initialization is usually quite fine. Especially if you're willing to copy or move it by returning a std::optional.
|
# ¿ Nov 20, 2015 07:08 |
|
sarehu posted:Not for general purpose use. sarehu posted:How? I can imagine it being true for a contrived type, like a not-null shared pointer, but realistically, how?
|
# ¿ Nov 20, 2015 07:55 |
|
Another way to make it clear that a variable is an output is good name choice. Of course, this all becomes a non-issue if you just output data by returning it instead.
|
# ¿ Nov 23, 2015 20:21 |
|
I would instead return tuple<optional<T>, std::string::iterator> or something analogous. Avoids copying/moving your entire remaining input (which might be arbitrarily large) as a bonus.
|
# ¿ Nov 24, 2015 00:14 |
|
Try compiling with AddressSanitizer or running inside valgrind.
|
# ¿ Nov 28, 2015 04:36 |
|
I don't find defining throwaway structs and accessing their members to be at all onerous Given that typing is certainly not the hard part of programming, a few extra characters compared to some ideal pattern-matching world is not a very high price to pay for unambiguous readability.
|
# ¿ Dec 4, 2015 08:09 |
|
Phayray posted:Derp, of course you guys are right, I was deleting them somewhere else but not clearing the vector. Saw it as soon as I looked at it this morning, I guess I just needed some sleep!
|
# ¿ Dec 5, 2015 19:33 |
|
Also try AddressSanitizer.
|
# ¿ Dec 16, 2015 19:54 |
|
Valgrind and asan are both handy for those because they tend to help isolate the cause of the bug rather than the symptoms.
|
# ¿ Dec 16, 2015 20:20 |
|
Hughlander posted:This is really well times part of the thread. Asan is exploding on a bad read from a dlopen in an android app. So some static being initialized somewhere in the 30 meg library is misbehaving. What are our options to track it down? I'm thinking of we could dump the .init of the elf we could get the order of init and add some logging to bisect it. But not sure if that's possible or if there's a better way.
|
# ¿ Dec 18, 2015 08:59 |
|
Hughlander posted:Sorry that was poorly written. It is finding a read overflow but gives no traceback just the PC and some registers. Running the PC through the sym file generated for brake pad doesn't show it as in our code at all.
|
# ¿ Dec 18, 2015 21:21 |
|
JawKnee posted:I'm getting a memory leak but I'm unsure what's causing it.
|
# ¿ Jan 6, 2016 07:22 |
|
JawKnee posted:I'm wrapping my head around these currently, or attempting to anyhow. Should I only be using smart pointers when something needs to be dynamically allocated?
|
# ¿ Jan 9, 2016 21:53 |
|
The Gay Bean posted:Assume I have several small bits of work to be done, that I want to parallelize. Each bit of work is small, and will be done at ~30 fps; the work must also be done sequentially (video encoding, if you're curious, but I'm curious about the general case). My current instinct on how to approach this would be one of two ways: Assuming this is purely CPU-bound work, you probably want to use a thread pool with a work queue. The thread pool can spin up exactly the number of threads that your hardware can execute most efficiently without any excess overhead.
|
# ¿ Jan 20, 2016 03:19 |
|
The Gay Bean posted:Yeah, I've used that approach in other cases, but the problem here (and something I omitted before) is that myWorker1, ... in this example all have an attached object/state for a video encoder. The encoder has to receive frames in order. I'm treating the encoder as a black box in this case - there are a lot of ways to parallelize video encoding but I'm not concerned with that for the sake of this example. (in actuality, each encoder state it spinning up threads internally as far as I can tell).
|
# ¿ Jan 20, 2016 03:29 |
|
The Gay Bean posted:My question is whether or not there is some theoretical reason why the above would be worse than having 4 persistent threads.
|
# ¿ Jan 20, 2016 06:42 |
|
Your continue statement is unnecessary. You can have your loop test any condition you like, but the question of "how do I handle user input" has wildly different answers depending on your environment.
|
# ¿ Jan 28, 2016 21:06 |
|
PRADA SLUT posted:If I put a cin somewhere, it will pause on the cin to wait for input, and thus, won't loop. Normally that's what I'd do, but I want the script to run indefinitely unless the user actually does something while it's looping.
|
# ¿ Jan 28, 2016 22:04 |
|
PRADA SLUT posted:What would be the simplest way to do this under OS X? Selecting on the standard input file descriptor should work there.
|
# ¿ Jan 29, 2016 01:25 |
|
If you want to use a for loop like that, the easiest approach would be to define an array of 4 ints, then in each iteration of your outer loop, repeatedly generate numbers until you get one that isn't in the part of the array you already filled in. Be careful not to examine elements of the array that you haven't filled in yet (they'll have undefined values). For something a little more modern and well-behaved than (s)rand, you might also want to look into C++11 random number generation. e: Also, not sure if you realize this, but standard convention is to do loops such that the counter starts at 0 and the the condition is < N for some N. This makes manipulating arrays more convenient. Ralith fucked around with this message at 08:22 on Feb 1, 2016 |
# ¿ Feb 1, 2016 07:52 |
|
PRADA SLUT posted:I noticed that after. It still outputs correctly.
|
# ¿ Feb 1, 2016 09:27 |
|
Clang tends to give more helpful errors in cases like this, so you might consider trying it next time you're deep in template shenanigans and nothing makes sense.
|
# ¿ Feb 9, 2016 04:32 |
|
JawKnee posted:there is no native tool for doing GUIs that is crossplatform though - I just went through trying to do this for an application I was working on. wxWidgets, GTK, Qt, Tk, ... I've recently learned that packaging GTK programs for non-linux is a huge pain though. wxWidgets is good at looking native on all platforms, so I'd try that first.
|
# ¿ Feb 27, 2016 22:30 |
|
Doesn't goto also skip destructors that would otherwise be called when control leaves a given block? That could cause all kinds of trouble, especially if you use RAII much.
|
# ¿ Mar 7, 2016 21:26 |
|
Sometimes refactoring is necessary to allow resource ownership to be explicitly encoded. Do it, preempt the otherwise nearly inevitable leaks, and try to plan ahead better next time.
|
# ¿ Mar 9, 2016 02:22 |
|
Volguus posted:I understand that and I agree ... usually ... but in this particular case the struct itself is the owner. It's possible for a poorly designed or sufficiently foreign library to force you to write ugly code, but I've worked extensively with that type of struct-with-a-pointer C API in e.g. libuv and never had trouble applying safe(r) resource management with it. Ralith fucked around with this message at 02:53 on Mar 9, 2016 |
# ¿ Mar 9, 2016 02:47 |
|
Xarn posted:What do I need to find out and replicate in a VM, to be able to precompile .o files in a VM that will link properly when used on the real machine?
|
# ¿ Mar 26, 2016 19:13 |
|
Harik posted:How do you setup an environment where --sanitize=memory works? I.E., I need a completely parallel set of libraries that only get linked in my test program, since the last thing I want is system-wide libc having memory tooling enabled. default.nix in your project dir: pre:with import <nixpkgs> {}; { my-dev-env = stdenv.mkDerivation rec { name = "my-dev-env"; version = "0.0"; buildInputs = [ cmake libuv libpng freetype SDL2 epoxy pkgconfig ]; }; } pre:$ nix-shell . (adapted from the wiki) Modifying the build process of existing packages to get features like msan set will take a bit more work but is fully supported.
|
# ¿ Apr 4, 2016 19:50 |
|
|
# ¿ May 17, 2024 10:03 |
|
Harik posted:I should do that. I've got three targets - amd64, arm-linux and arm-android-linux, and it while the builds are automatic the scripting is custom and somewhat fragile.
|
# ¿ Apr 5, 2016 20:50 |