|
Beef posted:Your business case is that the cost of upgrading to a compute environment from this decade is less than the cost of a certain programming going on a rampage and literally sacrificing security guideline managers on an altar to productivity. has this environment been audited by a trusted party for work in this sector? let me generate 200 hours of meetings to discuss. by the way, this won't impact the ship date, right? moving literally anything into a secure environment takes months of effort. i am incredibly glad i don't deal with that.
|
# ? Dec 15, 2016 13:01 |
|
|
# ? Jun 8, 2024 09:23 |
|
I have a make question, this seems like the best thread for it. We're using ar to create static libraries with a rule roughly like this:code:
|
# ? Dec 15, 2016 21:48 |
|
Normally you just unconditionally delete the .a first because updating the existing archive rather than creating it from scratch is not a meaningful optimization.
|
# ? Dec 15, 2016 21:53 |
|
Plorkyeran posted:Normally you just unconditionally delete the .a first because updating the existing archive rather than creating it from scratch is not a meaningful optimization. Fair enough, I can just add a delete to the recipe. Bizarre to me that it can't be accomplished with a flag to ar but it is what it is. Thanks!
|
# ? Dec 15, 2016 23:49 |
|
Is there a less verbose way to do this kind of extremely simple formatting? Does it need to take 3 lines and a variable to format some text???code:
|
# ? Dec 16, 2016 17:41 |
|
baby puzzle posted:Is there a less verbose way to do this kind of extremely simple formatting? Does it need to take 3 lines and a variable to format some text??? Either fmtlib or sprintf if you have to. Just be careful with sprintf, because it sneers at boring things like type safety
|
# ? Dec 16, 2016 17:57 |
|
Just use printf(). Don't use sprintf(), it's unsafe. If you need to format a C string, use snprintf() instead, since it won't cause buffer overruns. still no type safety though Doc Block fucked around with this message at 19:48 on Dec 16, 2016 |
# ? Dec 16, 2016 19:44 |
|
There's probably some library that does printf with variadic templates to make it magical and neat.
|
# ? Dec 16, 2016 21:54 |
|
One was even linked above.
|
# ? Dec 16, 2016 21:59 |
|
Clang will warn you if you're using a static format string that disagrees with the types of your arguments. Not as nice as a template solution, but enough to be comfortable using the printf family when it's called for.
|
# ? Dec 16, 2016 22:25 |
I'm looking into profiling a real-time application, but am not sure where to start. Once I've compiled my app with the -pg flag and debug symbols, how would I go about actually accessing the recorded timing data from within the app itself? E: The idea is that I'll ultimately be able to quickly test the performance impact of lots of different actions at the very least in real-time without closing the app and preferably from within the app itself. E2: Alternatively, how would I go about running an app like oprofile from within my app, then read the output back to the parent? I feel like something like that would set off a shittonne of security problems especially in Windows. Joda fucked around with this message at 23:50 on Dec 19, 2016 |
|
# ? Dec 19, 2016 23:23 |
|
I built some code that had a multiple defintions linker error that appeared on one machine but not another, with the same version of gcc (4.8.3 I believe). How can that happen? The code looked something likecode:
|
# ? Dec 22, 2016 14:15 |
Why would that be a problem? I may be wrong, but iirc if their signatures are different, they're treated as different functions by gcc/ld.
|
|
# ? Dec 22, 2016 15:32 |
|
Joda posted:Why would that be a problem? I may be wrong, but iirc if their signatures are different, they're treated as different functions by gcc/ld. Presumably, this is C, which doesn't have overloading. Not sure why it would be accepted inconsistently, though. Maybe it's getting compiled as C++ on one machine?
|
# ? Dec 22, 2016 15:42 |
|
eth0.n posted:Presumably, this is C, which doesn't have overloading. Not sure why it would be accepted inconsistently, though. Maybe it's getting compiled as C++ on one machine? Yeah it's C. It's the same cmake/make files in both places also, so getting compiled as c++ in one place doesn't really seem likely but ?? ? who knows
|
# ? Dec 22, 2016 15:47 |
|
netcat posted:Yeah it's C. It's the same cmake/make files in both places also, so getting compiled as c++ in one place doesn't really seem likely but ?? ? who knows dump symbols, if they are eye-stabbingly horrible, its compiled as C++
|
# ? Dec 22, 2016 16:03 |
|
I was a guest on CppCast this week talking about Regular Void and a few of my other standards proposals, for anyone who wants to hear my nasally nerd voice:
|
# ? Dec 23, 2016 16:59 |
|
Is there an existing implementation of a list that does the following? I just wrote my own implementation for fun, but now I'm thinking an existing library may have better performance and this was a bit crazy. - thread-safe bidirectional iterators for multithreaded access - iterator::Next() / ::Prev() continue to work even after the iterator was removed from the list. (And even if the original next/prev values were also removed.) This way one thread can delete elements while another thread is iterating over it and the iteration will not break. The contents are reference counted so they don't get erased until any iterator references also are gone. The first point is easy using a spinlock, but the second point ended up getting a bit more complicated than expected.
|
# ? Dec 25, 2016 23:46 |
Is there a simple C++ library (under MIT/similar) that just opens various popular image formats (png, bmp, tiff, jpg) and gives you a pointer to a simple array of color channel bytes? I've been looking around and there are a lot of image libraries but every single one of them seem to be geared towards image manipulation rather than simply opening and decoding (also, lots of them are under GPL.) There's SOIL, which is great if I just wanted to load a texture, but it doesn't offer a way to access the raw bit stream in local memory. I'm half considering just using libpng and having all my images as pngs, but I would like the option to load images in other formats without having to implement loaders for everything.
|
|
# ? Dec 29, 2016 00:07 |
|
OpenCV is BSD licensed and ridiculous overkill for your needs but it'll do the job with very little code. Load the image using cv::imread, that returns a cv::Mat from which you can get the channels (in BGR order!) using cv::split.
|
# ? Dec 29, 2016 00:39 |
|
I'm trying to write a program in C that parses a string containing 5 currencies and converts them to dollars, character by character with getchar(), so for example the input "$500£500¥500€500₹500" What I have works correctly except for a bizarre bug where the value after the amount in pounds always shows up zero, so the above input gives this output code:
code:
code:
|
# ? Dec 29, 2016 02:58 |
Don't you need to use wide characters to read your input for £/¥/€/₹ since they don't exist in ASCII?
|
|
# ? Dec 29, 2016 03:34 |
|
Joda posted:Don't you need to use wide characters to read your input for £/¥/€/₹ since they don't exist in ASCII? Yeah, those characters exist as multiple characters in stdin, you can use multiple getchar() calls to pull them out. ₹ is 0xE2, 0x82, 0xB9 That's not the problem though, it works fine except after a pounds-denominated value
|
# ? Dec 29, 2016 03:41 |
|
csammis posted:OpenCV is BSD licensed and ridiculous overkill for your needs but it'll do the job with very little code. Load the image using cv::imread, that returns a cv::Mat from which you can get the channels (in BGR order!) using cv::split. It also just wraps libpng/libjpeg/libtiff.
|
# ? Dec 29, 2016 04:32 |
|
Sure but is that a problem? I didn't get the impression that Joda is necessarily looking for bespoke image decoding libraries, just that they were looking to avoid writing wrappers around libjpeg/libpng/etc themselves
|
# ? Dec 29, 2016 04:54 |
Oh . I decided to take a look at the source code for SOIL to see if I could modify it to give me access to a CPU-side pointer rather than an OpenGL texture reference, and it turns out they use something called stb_image which looks like exactly what I'm looking for. Single-header, loads and saves all the usual subjects, not a lot of bloat. Wonder why it doesn't show up when you google for open image libraries/similar. E: Also, yeah I was just looking for a wrapper so I could avoid writing it myself. If I was willing to accept a lot of bloat, there were a couple of options, but I really wanted to avoid including a massive image manipulation library just to load some textures/images. Joda fucked around with this message at 04:59 on Dec 29, 2016 |
|
# ? Dec 29, 2016 04:56 |
|
Joda posted:Is there a simple C++ library (under MIT/similar) that just opens various popular image formats (png, bmp, tiff, jpg) and gives you a pointer to a simple array of color channel bytes? I've been looking around and there are a lot of image libraries but every single one of them seem to be geared towards image manipulation rather than simply opening and decoding (also, lots of them are under GPL.) There's SOIL, which is great if I just wanted to load a texture, but it doesn't offer a way to access the raw bit stream in local memory. OpenImageIO is the industry standard for image IO nowadays. Especially in VFX -- they support all manner of deep EXR malarky -- but it's useful in general and good to be familiar with. BSD licensed. To get raw pixel data you'd do something like code:
code:
Xerophyte fucked around with this message at 07:39 on Dec 29, 2016 |
# ? Dec 29, 2016 07:36 |
|
icantfindaname posted:I'm trying to write a program in C that parses a string containing 5 currencies and converts them to dollars, character by character with getchar(), so for example the input "$500£500¥500€500₹500"
|
# ? Dec 29, 2016 10:03 |
|
Dylan16807 posted:You're not initializing str when you malloc it. That could cause all sorts of weirdness. If I set the value of the pointer with strcpy(str, " "); it still gives the error
|
# ? Dec 29, 2016 23:45 |
|
icantfindaname posted:What the heck is the problem? Also that test should probably be a function so that you don't cause a problem like this. Also, when the character is an ascii character, your code might be more readable like code:
code:
roomforthetuna fucked around with this message at 03:48 on Dec 30, 2016 |
# ? Dec 30, 2016 03:45 |
|
Okay, the problem was in the dynamic allocation of memory for the holder string. Man, memory management is a nightmare
|
# ? Dec 30, 2016 04:51 |
|
C/C++ Programming Questions: Man, memory management is a nightmare
|
# ? Jan 4, 2017 23:20 |
|
Can I use CRTP to make mixin constructors? I don't think it's possible without UB but maybe there's hope:C++ code:
C++ code:
tractor fanatic fucked around with this message at 19:08 on Jan 7, 2017 |
# ? Jan 7, 2017 18:48 |
|
Where's the UB in your example? Aesthetically speaking, it might be a bit prettier if you used "explicit operator T&()" rather than "expose_base".
|
# ? Jan 7, 2017 22:31 |
|
Ralith posted:Where's the UB in your example? Is it OK to access a derived class's data from a base constructor? I thought until after the base constructor was finished, the object wasn't actually of the derived class's type. Is it defined what would happen if the derived class constructor also initialized "intval"?
|
# ? Jan 7, 2017 22:42 |
|
eth0.n posted:Is it OK to access a derived class's data from a base constructor? I thought until after the base constructor was finished, the object wasn't actually of the derived class's type. Is it defined what would happen if the derived class constructor also initialized "intval"?
|
# ? Jan 8, 2017 09:06 |
|
tractor fanatic posted:Can I use CRTP to make mixin constructors? I don't think it's possible without UB but maybe there's hope: For construction, it would be simpler (and completely legal) to do this, I think: code:
|
# ? Jan 8, 2017 09:33 |
|
Anyone have any idea why Visual Studio 2015 might seem to be ignoring my -Zm flag? I get the "use a higher -Zm value" error message even when I'm using the value it tells me to.
|
# ? Jan 8, 2017 18:05 |
|
Is anyone sitting on some good online resources for idiots grappling with C++? The OP was last updated just over six years ago and a bunch of the links are dead. I'm on my second attempt at this university course and have my final exam tomorrow, regardless of whether I make it or not I could really use something that'll help me understand stuff in the future. Stuff like keeping track of pointers, references and copies throws me off constantly, as well as deciding what goes in the header and what goes in cpp and so on. Basically C++ makes me feel really dumb. My first language was Java, for what it's worth. Not asking anyone to sit down and explain stuff to me, and not asking for anything that I can skim and somehow ace things tomorrow, just hoping that I can at some point understand this drat language better. So yeah. If someone's sitting on a great link or something, I'd love that.
|
# ? Jan 10, 2017 18:33 |
|
|
# ? Jun 8, 2024 09:23 |
|
C is really defined at a lower level of abstraction than Java. You can try to program in C++ like you would in Java, without worrying too much about how things work under the covers, and that's usually the right idea; but C++ exposes that lower level of abstraction in a lot of different ways, and it's that difference in abstraction levels that drives a lot of the rules and pitfalls of programming in C++, and you really do need to internalize that lower level of abstraction and at least the basics of how various ideas from C++ map down onto it before things will really "click" for you. That's why people often suggest learning C before learning C++; C is really just an inferior language in many ways, so for actually doing low-level programming it's not really a good idea, but for learning low-level programming it's much more direct, and then you can incrementally add in various C++ concepts and think about how they're implemented as you go. It's hard to make recommendations given that you have an exam tomorrow, because really I want to suggest that you first read some C material on pointers, headers, etc., but with that little time I'm afraid you'll just end up confused. Probably you should just have learned by this point in your university experience not to try to cram everything the night before the test.
|
# ? Jan 10, 2017 22:05 |