← Home ← Back to /g/

Thread 105968706

63 posts 12 images /g/
Anonymous No.105968706 [Report] >>105968713 >>105968757 >>105969079 >>105969080 >>105969674 >>105972369 >>105972913 >>105975622 >>105975637 >>105978121 >>105978646 >>105980295 >>105983643
What C++ Compiler Do You Use and What OS Do You Compile To?
Anonymous No.105968713 [Report] >>105968728 >>105969061
>>105968706 (OP)
GCC and bare metal.
Anonymous No.105968716 [Report] >>105981805
I don't give a fuck and he's literally Mossad and has no MIT affiliation whatsoever.
Anonymous No.105968728 [Report]
>>105968713
What do you make
Anonymous No.105968733 [Report]
Does Arduino count?
Anonymous No.105968739 [Report]
i compile to ur mom, she activate all my flags
Anonymous No.105968757 [Report] >>105968856
>>105968706 (OP)
Clang, my own fork that implements my own version of c++
Windows
Anonymous No.105968856 [Report] >>105969079 >>105972869
>>105968757
Why do you need your own fork? What's different about your fork that it didn't have originally?
Anonymous No.105969061 [Report]
>>105968713
arm-none-eabi-gcc ftw
Anonymous No.105969079 [Report] >>105969651
>>105968706 (OP)
Clang (my own fork that compiles to my own version of C++)
Linux

>>105968856
Because Bjarne is a retard incapable of designing an elegant language.
Anonymous No.105969080 [Report]
>>105968706 (OP)
Anonymous No.105969651 [Report] >>105972874
>>105969079
Yeah but what did you change
Anonymous No.105969674 [Report]
>>105968706 (OP)
I wish Lex would just stop making these shit videos and apologize for all of his lies.
Anonymous No.105970113 [Report]
jude
Anonymous No.105971736 [Report]
sauce?
Anonymous No.105972335 [Report] >>105972849
I just started learning C++ this week. I use g++ on Linux
Anonymous No.105972369 [Report]
>>105968706 (OP)
I can't stand this boring cunt. I bet he talked about love
Anonymous No.105972849 [Report] >>105973737 >>105979062
>>105972335
this is a schism post.
I hate gcc/clang on linux because address sanitizer has leak sanitizer built in and ANY gui library is going to have false positives (mainly nvidia drivers / fonts), it would be fine if I could build with a flag to disable it, but you can't, and the suppression file still shows report (suppressed), and skipping dlclose can hide useful leak in libraries. So I set a environment variable in my IDE to disable it.
With msvc, it won't check for leaks. Leaks are not a big worry on C++, and asan does not detect uninitialized memory errors, while valgrind / dr memory can (but valgrind/dr memory can't detect a lot of other errors Asan checks such as off by 1 stack corruption).
Also I love msvc iterator debugger, it has stopped be from being a retard. With gcc/clang you can use _GLIBCXX_DEBUG.
If you want more paranoia regarding numeric under / overflow casting, I suggest using clang with undefined behavior sanitizer with:
-fsanitize=unsigned-integer-overflow -fsanitize=implicit-conversion
and these are also not enabled by fsanitize=unsigned on clang:
-fsanitize=nullability -fsanitize=local-bounds
GCC has ubsan, I think it doesn't check for signed overflow because it has ftrapv instead (ftrapv does not work for narrowing conversions, it does work if you do +1 after INT_MAX), but gcc doesn't have anything to check for unsigned overflow.
If you had a intentional overflow, you would cast it (static_cast or C cast). This is very bad to combine with a narrowing warning (like -Wconversion unless you manually disable it for each case, not possible, I use clang-tidy because //NOLINT is easier) because otherwise the only way to remove the warnings is if you cast it, which ignores ftrapv and ubsan's overflow detection (if it's unintentional to over/underflow).
Anonymous No.105972869 [Report] >>105973045
>>105968856
I am adding any feature I can think of.
A few notable features.
1. Allow class methods to be defined without being forward declared in the class body. This solves the issue of private leaking into the public interface.

2. Heterogeneous initializers for arrays
This feature takes whatever arguments you pass it and flatten them into bytes. Its purpose is to generate data tables with multiple struct types.

[[heterogeneous_bytes]]
unsigned char arr[] = {
<expressions of any type>
};

3. named array elements.
A complimentary feature to heterogeneous initializers, that allows giving specific elements a name. This can later be used with __builtin_offsetof, to get the byte offset of a named element. You can use this to generate complex tables that use offsets to reference other parts of the table.
Labels start with a colon, the reason being this is just what syntax was unused.

unsigned char arr[] = {
:<label name> <initializer expression>
};
Anonymous No.105972874 [Report]
>>105969651
nta but i did the same, i added syntactic sugar and re-designed the standard library to feel more like rust, but kept c++ style declarations
Anonymous No.105972913 [Report]
>>105968706 (OP)
Digital Mars C on XP.
Anonymous No.105973045 [Report] >>105973550 >>105979137
>>105972869
Here are a few I would have thought of:
1. Adding Java-style array declarations:
int[] a;
// instead of int a[]
// note that things like std::make_unique<int[]>(10) are already valid

2. Rust-style using statements:
using a::b; // equivalent to namespace b = a::b;
using std::*; // equivalent to using namespace std;
using std::a::{b::B, c::{C, D}, e::*, f::{self, F, G}}; // more complicated example

3. Java-style annotations syntax instead of the new upcoming reflection annotation syntax
using clap::{Help, Long, Short};

struct Args {
@Help("Name of the person to greet")
@Short
@Long
String name;

@Help("Number of times to greet")
@Short
@Long
int count = 1;
};

// original code:
struct Args {
[[=clap::Help("Name of the person to greet")]]
[[=clap::Short, =clap::Long]]
std::string name;

[[=clap::Help("Number of times to greet")]]
[[=clap::Short, =clap::Long]]
int count = 1;
};

4. Interfaces like C# and Java and an abstract keyword (because using pure virtual functions to declare abstract classes kind of sucks)
abstract class W { ... };
class X { ... };
class Y { ... };
interface IA { ... };
interface IB { ... };
class Z extends W, virtual X, virtual Y implements IA, IB { ... };

Anyway, nothing revolutionary, but still interesting to think about.
Anonymous No.105973550 [Report]
>>105973045
These would be grear, actually. C++ has some notoriously ugly syntax compared to Java.
Anonymous No.105973737 [Report] >>105974637 >>105975007 >>105975189 >>105979062
>>105972849
>all this nonsense instead of using rust
Do cniles really
Anonymous No.105974637 [Report]
>>105973737
sunken cost
Anonymous No.105975007 [Report]
>>105973737
I don't think I have seen anyone actually programming like that, that's just me.
I think a normal person just turns on the sanitizer and they don't care about warnings, or they just turn on Wconversion and just patch all the warnings with casting.
Anonymous No.105975189 [Report] >>105977346
>>105973737
nobody uses rust
Anonymous No.105975622 [Report]
>>105968706 (OP)
linux: clang for development, gcc for release
mac: appleclang
windows: msvc
Anonymous No.105975637 [Report]
>>105968706 (OP)
lex talks about dvorak, split keyboards, neovim and all that nerd shit. all markers for someone who can't code
Anonymous No.105975860 [Report]
I saw Lex Fridman at Drexel once. I told him how cool it was to meet him in person, but I didn’t want to be a douche and bother him or ask for photos or anything.

He said, “Oh, like you’re doing now?” and gave me this long, expressionless stare.

I was taken aback, and all I could say was “Huh?” but he kept cutting me off and going, “Huh? Huh? Huh?” while slowly typing on one of those split keyboards that wasn’t plugged in.

I said, “I really liked your interview with Elon,” and he said, “He liked it too. He told me telepathically.”

Then he pulled out an MIT lanyard from his backpack (no ID, just an empty lanyard) and stared at it for like thirty seconds. Finally he whispered, “Can we steelman the case for credentials being a social construct?”

I didn’t know what to say, so I just nodded.

When I was leaving later, I saw him trying to walk out of the engineering building with like five Raspberry Pis and a bag of ethernet cables without signing them out.

The lab tech was super chill and professional, and was like, “Sir, you need to check those out first.” At first he acted like he didn’t hear her and just stared at the floor, but eventually he turned back and placed them on the desk one by one.

When she picked up one of the cables and started scanning it multiple times, he stopped her and told her to scan them each individually “to prevent any malignment” Then he turned around and winked at me.

I don’t even think that’s a real word.

After she logged everything and handed him the checkout form, he interrupted her by yawning really loudly. Like over and over. Just loud, deliberate yawns.

I watched him carry it all outside until he got into the back of a Tesla and it drove off.
Anonymous No.105977346 [Report] >>105977984
>>105975189
c is for subhumans and rust is aryan
Anonymous No.105977432 [Report]
Clang to WebAssembly because I hate my life.
Anonymous No.105977456 [Report] >>105977872
anything else than clang is trolling yourself. first because of clangd. second because GCC is just trash and can't into errors
Anonymous No.105977872 [Report]
>>105977456
clang is good because it is natively c++
captcha: TNDWH2
Anonymous No.105977984 [Report] >>105978596
>>105977346
nice larp. rust is for trannies like (you)
Anonymous No.105978121 [Report]
>>105968706 (OP)
I would like to use clang but life forces me to use msvc.
Anonymous No.105978596 [Report]
>>105977984
>saaaaar please let me insert my gay lisp code so i can show you how much of a tinkertranny i am
kys fag
go back to your cs101 class and stay there
Anonymous No.105978646 [Report]
>>105968706 (OP)
>What C++ Compiler Do You Use
gcc
>What OS Do You Compile To?
Uhm, ackshually, don't you mean object file format and architecture?
Anonymous No.105979062 [Report] >>105979204
>>105972849
you should try -Wconversion. I compiled an old project of mine with it and it gives really good insights (both clang and g++). Nevertheless, you're right that clang generally has better diagnostics and tooling. It's also more tightly integrated with IDEs (clangd, ccls, clang-tidy, clang-format etc..). That said, I still prefer building with gcc for release mode, there are just some edge cases where it'll perform slightly better than clang. And it also supports much more stuff out of the box, like cross compilation.

For integers behavior, gcc (and clang) let you customize the behavior with these options:
https://www.gnu.org/software/c-intro-and-ref/manual/html_node/Signed-Overflow.html
On most systems, INT_MAX+1 == INT_MIN, but that's not always the case, which is why gcc lets you force this behavior for systems where that's not the default.

>>105973737
Bro I'd like to use it, in fact I use it for personal projects, but it's just not there in the entreprise world. Only offer I've got was for a crypto company (web backend) that went under after 6 months. Feels like an insult using rust for web backend.
Anonymous No.105979137 [Report] >>105979220 >>105979613 >>105979640
>>105973045
My honest opinion is that they should drop the current syntax. There are many issues with is, such as this being the recommended default for accessors:
class Whetever
{
[[nodiscard]] constexpr const decltype(auto) GetX() nothrow const { return this->value; }
};

The amount of boilerplate is insane. That said, the language is awesome, the features that C++ has (especially talking about constexpr and templates) are things that are unlikely to be seen in any other compiled language ever.

I think they really should come up with a new syntax. Herb sutter's experiment looked really promising.
The standard should state that every file under the extension "cpp2" or "hpp2" must be using the new syntax.
Anonymous No.105979204 [Report] >>105979409 >>105980312
>>105979062
c23 added macros that tell you if you had overflow.
you can write the functions yourself if you don't use c23.
add(&sum, lhs, rhs)
{
if (INT_MAX - rhs > lhs) ( handle overflow )

you fill in the rest, youre smart
}
Anonymous No.105979220 [Report] >>105979409 >>105979575
>>105979137
mmhmm but when i post this shit all the sepples yell at me that it's contrived
Anonymous No.105979409 [Report]
>>105979204
overflows and underflows usually happen in places where you don't expect them. Like your coworker running a 'i-1' on an array, while forgetting to handle the case where i = 0, leading to segfaults.

>>105979220
the code I posted is what the official c++ guidelines recommend. Your code should not take a reference for arithmetic values as those are often small (half a word for int, single word for long on x64).
You should do something like this instead:
template <typename T>
requires std::is_arithmetic_v<T>
[[nodiscard]] static constexpr auto add(T&& a, T&& b) noexcept -> T
{
// Arithmetic types are trivially copyable on most architectures, but forward just in cast
return std::forward<T>(a) + std::forward<T>(b);
}
Anonymous No.105979575 [Report]
>>105979220
>implying the C version isnt valid in C++ and not what most people in C++ would just write anyway
nice try cniletranny
Anonymous No.105979613 [Report] >>105980166
>>105979137
Never liked cpp2. The syntax is quite horrid.
I just want Java-style declarative syntax that is easy to read and understand and any Rust or C# style syntactic sugar that might be worth adding.
If C++ abolished C-style syntax, it would become another irrelevant memelang.
>hpp2
A redesigned C++ should have no headers at all, only modules.
Anonymous No.105979640 [Report] >>105980119 >>105980166
>>105979137
>constexpr const
wtf, why?
constexpr is already const, so whats the point
am i missing something
Anonymous No.105979652 [Report] >>105980186
checking for overflow by doing the arithmetic op is a rookie mistake. Compilers will always """optimize""" it as if it could not happen because they decided UB means fuck you that's why.
And doing any sort of limit comparisons is fucking retarded, especially for multiplication.
GCC and clang have __builtin_add_overflow which gives you boolean. It compiles to carry flag on most architectures, which is how you should check for overflow in assembly anyway.
Actually not sure what it does on risc-v since they don't have carry
Anonymous No.105980119 [Report]
>>105979640
yo bro i heard you like const dot jpeg
Anonymous No.105980166 [Report] >>105980494
>>105979640
'constexpr' means the function can be run at compile time, it has nothing to do with the return value, which is what the 'const' is for.
I messed up my post but the return value should have been inside parenthesis, so that 'decltype(auto)' would make the function return an lvalue (as opposed to simply auto which would return an rvalue).

>>105979613
headers would likely still be needed, they're required when you want to distribute a proprietary shared object/dll while still allowing people to make code that links to it.
Anonymous No.105980186 [Report] >>105980312 >>105981676
>>105979652
this, some anon the other day posted this retarded code:
int inc_will_overflow(int x)
{
if (x + 1 < x) return (1);
return (0);
}

Now, gcc and clang CAN make overflow a defined behavior with -ftrapv and -fwrapv but that's not in the standard.
Anonymous No.105980261 [Report]
the only right answer will always be ISPC
Anonymous No.105980295 [Report]
>>105968706 (OP)
SAS/C / AmigaOS
Anonymous No.105980312 [Report]
>>105980186
that is the wrong way to test for overflow
see >>105979204
Anonymous No.105980494 [Report] >>105980529
>>105980166
>headers would likely still be needed, they're required when you want to distribute a proprietary shared object/dll while still allowing people to make code that links to it.
At that point it should just call C by foreign function interface and have bindings to the new C++ from it. The library will likely have some kind of C header, it would just make sense to do it the same way Rust does.
Anonymous No.105980529 [Report] >>105980648
>>105980494
no it doesn't
Anonymous No.105980566 [Report]
At work? gcc and linux, while making sure it also compiles with clang and in some cases for windows.
At home? gcc and linux only, I don't give a shit about breakage for any meme system.
Anonymous No.105980648 [Report]
>>105980529
>reeeeeee muh rust bad
no one even talked about rust
they only mentioned rust as an example of a language for binding to C you retard
Anonymous No.105981676 [Report] >>105983349
>>105980186
ftrapv fwrapv and fsanitize=signed-integer-overflow
do not check for overflow of narrowing conversions.
If you initialized a narrow value from a overflowing value, it will be ignored.
the check is only applied for operations on that value, like addition.
You need -fsanitize=implicit-conversion from clang for this situation, and you may want to enable -fsanitize=unsigned-integer-overflow if you are willing to handle unsigned numbers.
Anonymous No.105981805 [Report]
>>105968716
Do they use him for the new Epstein, or does he have too much recognition for that?
Anonymous No.105983349 [Report] >>105983492
>>105981676
not a problem in rust
Anonymous No.105983355 [Report]
None.
Anonymous No.105983492 [Report]
>>105983349
I would use rust if it didn't look like late stage modern C++ code.
Don't worry anon, I'll probably use whatever the hot jazz programming language people end up using in 10 years.
Ideally something like go but with magical lifetimes (C++ would also have magical lifetimes if that was the case, but I really want to stop using C++, but we need a operating system that's built/re-written with go or something, I think one day, AI could probably do it).
Anonymous No.105983643 [Report]
>>105968706 (OP)
Microsoft's one because it's the only one that supports modules and C++ is unusable garbage without them.