|
FastEddie posted:No, they're bitwise shifts, because they operate on bits, rather than the boolean interpretation of the collections of bits. I have no idea what a logical shift would be. I think the way it works is, if the object is unsigned, >> does a logical shift and the sign bit is not preserved. If the object is signed, it does an arithmetic shift which keeps the sign bit.
|
# ¿ Feb 17, 2008 07:11 |
|
|
# ¿ Apr 20, 2024 04:29 |
|
floWenoL posted:No, if the integer is signed and negative, the behavior is implementation-defined.
|
# ¿ Feb 18, 2008 21:12 |
|
Plastic Jesus posted:I came across this a year or two ago: His only argument is that multiple inclusions slow down the compiler. My response would be: Yes? And?
|
# ¿ Mar 27, 2008 00:25 |
|
floWenoL posted:And compile time is a major bottleneck for large C/C++ programs. Pike's advice might be outdated, but including (non-system) headers willy-nilly is a good way to kill compile performance. And anyway, everyone knows long compiles are an excuse to goof off for a while.
|
# ¿ Mar 27, 2008 18:41 |
|
Nahrix posted:
|
# ¿ Nov 25, 2008 17:49 |
|
The return value of system() is kind of funky. You need to use the WEXITSTATUS macro to get the actual exit status of the command. Something like:code:
|
# ¿ Oct 6, 2011 19:32 |
|
Rottbott posted:I'm surprised people like it so low. My Visual Studio layout on my work PC can fit over 200 columns. Our existing C codebase with parts dating back to 1997 frequently exceeds 100 columns. A limit of 80 would drive me nuts.
|
# ¿ Oct 25, 2012 22:38 |
|
sarehu posted:If you wrote
|
# ¿ Sep 18, 2014 18:42 |
|
I would not have been able to build with -Werror at my last job due to warnings coming from system and boost headers.
|
# ¿ Feb 13, 2015 19:33 |
|
Xarn posted:Yep, recursive make means makefile that goes into a subfolder and calls make from there. This breaks deps, paralelization and similar things. Not if you do it right. But then, that kind of applies to most everything.
|
# ¿ Apr 3, 2018 20:34 |
|
qsvui posted:A reminder that even the C standards committee decided that VLAs were a mistake and made them optional in C11. VLAs were fine and I used them in production code. Come at me.
|
# ¿ Aug 3, 2018 22:27 |
|
Xeom posted:Preferably something that can be called hundreds of times a second with little overhead. This is the point where I usually ask, wait, what are you trying to do?
|
# ¿ Sep 3, 2018 02:43 |
|
Hatsune Mike posted:In C, I'd be happy doing something like this: There's nothing really stopping you from doing the exact same thing in C++, except for maybe your coworkers who review your code (if you do that) and people on the Internet who will fret about violating the purity of OOP.
|
# ¿ Jun 22, 2019 20:57 |
|
Dren posted:Hard disagree. cmake is much nicer than a pile of crusty make garbage.
|
# ¿ Dec 17, 2020 18:45 |
|
Zopotantor posted:Floyd's cycle detection algorithm, which every programmer ought to know
|
# ¿ Feb 20, 2021 18:07 |
|
Volguus posted:I always hated begin and end and typing := (although it's easier and clearer to read).
|
# ¿ Mar 6, 2021 00:00 |
|
I would leave it the way it is and tell the static analyzer to gently caress off But that's just me.
|
# ¿ Sep 8, 2021 18:00 |
|
Rocko Bonaparte posted:My more fundamental problem is I've been doing a lot more OOP for the past ... 20-odd years (drat) and the code reuse monkey on my back is screaming about what I'm doing.
|
# ¿ Oct 8, 2021 20:47 |
|
ExcessBLarg! posted:You shouldn't place functions in headers unless they're inline
|
# ¿ May 10, 2022 20:22 |
|
I use quotes for headers that were written by us, and angle brackets for anything out of my control. You know, the way God intended.
|
# ¿ Jul 19, 2022 00:20 |
|
Once in a while you'll see someone do:code:
Oops.
|
# ¿ Jan 4, 2023 06:44 |
|
Comma operator has entered the chat
|
# ¿ Mar 6, 2023 19:59 |
|
I think any compiler should refuse to compile that, out of principle.
|
# ¿ Apr 5, 2023 01:48 |
|
rjmccall posted:Words I've been programming C++ for over 20 years now, and I have no idea what you just said.
|
# ¿ Apr 5, 2023 02:38 |
|
His Divine Shadow posted:C++ code looks so loving incomprehensible to me compared to regular C. Tbf that example is a pathological case and if you submitted a PR with that code in my workplace people would be asking what kind of drugs you were on.
|
# ¿ Apr 5, 2023 18:18 |
|
You are closing all these fds too at some point, right?
|
# ¿ May 28, 2023 05:18 |
|
You're right. It should be an error.
|
# ¿ Nov 3, 2023 02:49 |
|
chglcu posted:Especially when sickos put the opening brace on its own line. Our style guide at my job mandates Allman style braces.
|
# ¿ Nov 3, 2023 20:04 |
|
roomforthetuna posted:Sometimes you close and it's an else or the while of a do-while.
|
# ¿ Nov 4, 2023 06:36 |
|
roomforthetuna posted:Yes it still is sometimes an else after a brace, you're just saying you should format that like a maniac. You appear to be suggesting this monstrosity?
|
# ¿ Nov 4, 2023 16:51 |
|
|
# ¿ Apr 20, 2024 04:29 |
|
Don't worry about it too much, Strong Sauce. You're not doing anything *wrong*, per se. Writing C++ is an eternal quest about writing your code and then figuring out how you can make it better.
|
# ¿ Feb 17, 2024 19:36 |