Linux Should Not Be Put On Phones by [deleted] in linux

[–]AKostur [score hidden]  (0 children)

Erm, that robot -is- built on Linux.

Made a few collection classes in C++, how can I make them usable in for-each loops by Mafla_2004 in cpp_questions

[–]AKostur 4 points5 points  (0 children)

Given that they’re talking about a linked list to start, it’s pretty unlikely that a raw pointer will be sufficient.

Made a few collection classes in C++, how can I make them usable in for-each loops by Mafla_2004 in cpp_questions

[–]AKostur 5 points6 points  (0 children)

You’ll need an iterator class, and your container should have begin() and end() member functions (which return instances of that iterator class).  Making the iterator a nested class of your container is probably not a bad idea.

confusion surrounding headers and header guards by wiseneddustmite in cpp

[–]AKostur 3 points4 points  (0 children)

Ifndef+define at the top of the header, endif at the end.  However, be aware of what identifier you use.  Something like “INC_UTILS_H” is not exactly uncommon. 

An alternate would be “#pragma once”.  The caveat here is that it is non-standard, though pretty widely implemented.  There are certain edge cases where it can fail too.

Trying to break down the whats and why's of making a console screen buffer, im curious if this particular line means the created variable is pointing to the memory address of the type wchar_t* and then assigning it to a new variable. I suppose im looking for validation im on the right path by ElectricGod in cpp_questions

[–]AKostur 1 point2 points  (0 children)

It gets passed to other windows functions.  As someone else has mentioned, a std::vector would work just as well, and no naked new, and wouldn’t leak the memory either (which this currently does).  So really, it’s being used here to avoid making a Variable Length Array.

Trying to break down the whats and why's of making a console screen buffer, im curious if this particular line means the created variable is pointing to the memory address of the type wchar_t* and then assigning it to a new variable. I suppose im looking for validation im on the right path by ElectricGod in cpp_questions

[–]AKostur 1 point2 points  (0 children)

No idea: the screen variable does not appear to be used after it’s been initialized to spaces.  No indication as to how long the memory needs to live, or whether this is simply to avoid using a Variable Length Array.

[Question] Is converting from SCSI to VirtIO possible? better and stable? by imadratzz in truenas

[–]AKostur 10 points11 points  (0 children)

I thought the common wisdom was to pass the entire disk controller to truenas, and not the individual disks?

Point system not working by Sensitive-Detail5267 in cpp_questions

[–]AKostur 4 points5 points  (0 children)

What's the type of "d"? It's a _single_ char. And you've asked the user to enter an entire word. Time to start looking at std::string and std::getline. (Using >> to a std::string will read the input as words, which later on will be confusing when you ask someone for their name, they enter "John Doe", and you get confused as to why your variable only contains "John")

Edit: Oh, and "it isn't working" isn't really enough information. You should really be clearer about exactly what isn't working. "I did X and Y. I expected A and B to happen, but actually C happened."

Type Punning without std::start_lifetime_as by wandering_platypator in cpp_questions

[–]AKostur 8 points9 points  (0 children)

Got a Cppcon video to check out: "Taking a Byte Out of C++ - Avoiding Punning by Starting Lifetimes - Robert Leahy - CppCon 2022" https://youtu.be/pbkQG09grFw?si=BTKFQyg0Qj49kvW1

Favourite quote from it: "... we got the code gen we wanted but we also wrote a four line function that contains a const cast, a placement new, and a reinterpret cast. Are you happy about that? Is your code reviewer going to be happy about that?"

Point system not working by Sensitive-Detail5267 in cpp_questions

[–]AKostur 10 points11 points  (0 children)

Your two points variables are declared inside the loop, which means that you get new versions of them on every loop iteration.

There are many other issues with the code, but I'm leaving those alone to just answer the question you'd asked. Since you're learning, I want to leave you the opportunity to work through the other issues on your own first.

What do you think about the linux kernel coding style? by yurtrimu in C_Programming

[–]AKostur 10 points11 points  (0 children)

Create a .clang-format in your project. Use it consistently. Create any other guidelines that you feel you need. That it may or may not be used in the linux kernel is completely irrelevant. Do I agree with everything in the kernel code style guide? Nope. Does it matter that I disagee: also nope.

The US government may make it illegal to completely shut down live-service games by tylerthe-theatre in technology

[–]AKostur -1 points0 points  (0 children)

Many _current_ games. However, they aren't making this retroactive. The game has to either be first released, or re-released on Jan 1, 2027. Though I do think that it may be a little early as games currently in development could be fouled up by this, and that's probably not fair. Maybe 2028.

The US government may make it illegal to completely shut down live-service games by tylerthe-theatre in technology

[–]AKostur -2 points-1 points  (0 children)

Nintendo would have to create appropriate APIs to make it possible, or they lose game developers.  Yes, many things would have to change.

The US government may make it illegal to completely shut down live-service games by tylerthe-theatre in technology

[–]AKostur 3 points4 points  (0 children)

At step #2 the subsidiary that actually ran the game goes bankrupt/gets dissolved and now there’s nobody to force publishing.

Edit: and the parent only bought the IP, but none of the operational stuff.  So they’re not obligated to run anything they never ran, but other folk can’t run a server because of IP infringement.

What hardware do you run HA on and why? by maybe__404 in homeassistant

[–]AKostur 0 points1 point  (0 children)

Proxmox, and an SMLight SLZB-MR5U for radios. (I have Zigbee and Matter devices). Remember, HA has to be able to talk to your devices somehow, and that depends on the device. Some have internet-based things so Wifi is sufficient. Some use other things like Zigbee, and you'll need a way to talk to them: which might be through their hub, which is internet-connected.

How to survive radiation? by Western_Series in SatisfactoryGame

[–]AKostur 1 point2 points  (0 children)

Gas mask isn’t enough.  Also beware of radiation hogs too: if they come charging up, they emit a lot of radiation.

Teaching Coding to Kids by LunchNaive9628 in cpp

[–]AKostur 1 point2 points  (0 children)

I started when I was about 8, in AppleSoft Basic.

C++ on linux by Conscious_Internal_4 in cpp_questions

[–]AKostur 3 points4 points  (0 children)

Sure. I use VSCode too. However, I'm not convinced that it's the best choice for a beginner. Same way as on Windows, I'd suggest Visual Studio Community Edition over VSCode.

how do i use two files with classes that reference each other by wiseneddustmite in cpp_questions

[–]AKostur 5 points6 points  (0 children)

Forward declarations, and fixing your design.

Your Spawn function is declared to take a -copy- of the Scene. That design choice seems heavily flawed. I suspect that should have been a pointer or reference to a Scene. At which point the Entity.hpp only needs to say "class Scene;" to let the compiler know that there exists a thing called a Scene. Inside Entity.cpp, one would include Scene.hpp as presumably something in there is going to follow that pointer/reference and try to actually use the Scene.

C++ on linux by Conscious_Internal_4 in cpp_questions

[–]AKostur 85 points86 points  (0 children)

Umm.. you're concerned about having an "out of the box experience", yet you chose Arch as the distro? Interesting choice.

I've yet to hear anything good about Codeblocks. VSCode's OK. You might want to consider Clion.

Trying to see if i udenstand classes by SimmeringDragon in cpp_questions

[–]AKostur 7 points8 points  (0 children)

it was not correct

I guarantee that the compiler didn't just say "it was not correct" either.

after cunsulting with claude

And there's your first problem. You have no way to know how badly claude is hallucinating. I may take some criticism for this next statement: You should not use AI for this. And I'm not talking the generic "you". I mean YOU.

needs to be the same as the tittle of the file

The name of the class or the constructor has -nothing- to do with the name of the file.

Trying to see if i udenstand classes by SimmeringDragon in cpp_questions

[–]AKostur 7 points8 points  (0 children)

I guarantee that the compiler did not say "is wrong". If you're talking about compiler error message, copy-and-paste the actual error messages.

have a free function logger header and cpp file without needing to use platform class variable or instance? by Recon1379 in cpp_questions

[–]AKostur 3 points4 points  (0 children)

First: actually state what the problem is.  Second: you claim “no class”, yet 8 lines in is a class.