Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Strong Sauce
Jul 2, 2003

You know I am not really your father.





I'm starting up (or rather my company I work for) on C++. I have not done C++ since Turbo Borland was still being used at my high school.

We're doing multiplatform right off the bat and using C++17 standards. I believe we're mostly using Clang, except we're also supporting Windows (which I believe is a separate compiler). We do have CMake files now to build out all the platforms we're on, but otherwise... what else? Is there a site that lists compatibility issues between both the compilers I'd have to watch out for, and also between different platforms I should be aware of? As an example, don't use the long modifier (for int) because they're defined differently for windows vs linux.

Sorry to just jump in but the OP hasn't been updated in a while so hopefully not too much of a dumb newb question.

Adbot
ADBOT LOVES YOU

Strong Sauce
Jul 2, 2003

You know I am not really your father.





Thanks for all the info. We actually do have our build system up, but I've been kinda tasked with being the subject matter expert when it comes to debugging our issues and also coming up with best practices for our team to write in C++. For example some people are writing int64_t while others have written long long. So I'm looking around for any guides for that kind of stuff as well. I've seen cppreference.com through my searches but besides using it as a quick reference it seems a bit intimidating to read straight through.

Conan looks pretty interesting and we are using Artifactory/JFrog. They also have a community version where we can run our own instance but i'll have to get permission to deploy that on a server. Right now we're kinda bumbling through our package management. Especially since we have to share our code with other teams.

Are there any other resources I should take a look at? Anything that helps people who haven't done much C++ since before standardization? Thanks for all the tips!

Strong Sauce
Jul 2, 2003

You know I am not really your father.





The project I'm working on had to extract info from the Windows registry using TCHAR/DWORDs. From reading around TCHAR=char if the application is Ansi, which as I understand no one would normally do. So for all intents and purposes, TCHARs are all wchar_t.

Reading around it seems like Unreal Engine has some justification for using TCHAR but everyone else seems to recommend against using TCHAR.

So what's the correct recommendation / context for this? It seems like I should directly use wchar_t but I want to explain why I went ahead and changed all the types in the PR. Is it reasonable to just say all modern apps are UTF-8 encoded so there's no need for TCHAR since its just going to be a wchar_t type anyways?

Strong Sauce
Jul 2, 2003

You know I am not really your father.





ullerrm posted:

The first two paragraphs are correct. But Windows rarely uses UTF-8 -- most of its APIs accept or produce UTF-16, and wchar_t is a uint16.

Most Win32 APIs will have ANSI and Wide versions for each call, and a macro that switches between them. For example:
* RegGetValueA() will take a const char* for the value name parameter (and interprets it using the current Windows codepage)
* RegGetValueW() will take a const wchar_t* for the same.
* RegGetValue() (without the A/W) is #defined to the W version if UNICODE is defined, otherwise the A version

So, what you probably want here is:
* Anywhere you're using TCHAR, use wchar_t or WCHAR instead.
* Always explicitly use the W version of Win32 calls, instead of the generic ones
* If you need to consume or produce UTF-8 data, you'll need to convert between UTF-8 and UTF-16 (use MultiByteToWideChar / WideCharToMultiByte with CP_UTF8 as the code page)

Bruegels Fuckbooks posted:

the use case for tchar is if you have to support a non-unicode build (like maybe you want your product to work on windows 98). you probably don't want to do that anymore in 2023.

thanks for this! good info to have

Strong Sauce
Jul 2, 2003

You know I am not really your father.





Okay so I posted in August or so about starting a new project in C++, something I've not worked in since my high school days.

My current progress: how the hell am i suppose to know any of this poo poo in C++?

We were able to find someone in our company who is experienced with C++ to take a look at our PRs and he has been pretty helpful.

I wrote a class as a simple storage class. Basically a dict to handle values. I created basic constructor/destructor functions that didn't do anything so I left them blank.

He wrote up a whole thing suggesting how we should set those constructors/destructors to default (i.e. `Dict() = default;`, `~Dict() = default;`) because this allows the memory APIs to be able to set std::is_trivially_copyable_v<T> to return true. This apparently allows std::memcpy, and std::memmove to copy the object faster. He also says even if you're not using your class for much, this is just good practice in his opinion.

I guess my question is: regardless of what you think about his opinion.. is this something I should actually know while I'm working in C++? granted I've only been doing this for maybe half a year but is this just how it is with C++? As you write more code you just kinda figure out these details about C++?

I'm not sure exactly if I just haven't studied enough about C++ or this is just how it is until you gain enough experience writing C++ code. Interested in what people have to say because it just seems like something you'd never know about until you ran into it.

When I posted in here originally people suggested I look at cppreference.com which I went to look at after I found out about that tidbit above and lo and behold it does mention it in the Classes section of the site about triviality, but short of looking for this information I probably wouldn't have found it. Hell even reading that section, I probably would have read it, thought, "okay I guess I need to know about this" but probably would have written my code the same way.

Strong Sauce
Jul 2, 2003

You know I am not really your father.





Thanks everyone for your sympathetic words. I kinda avoided this thread today because I was pretty exhausted from dealing with C++ at work that I wrote that out of frustration and didn't want to deal with anything C++ today.

I do feel like I'm a bit too old to be putting so much more esoteric knowledge into my brain. I'm stalling a bit in my career right now and I honestly don't know if trying to become an expert on C++ is the thing that reinvigorates my enjoyment of programming or of my job. There are probably lucrative jobs to be had with this skillset but I do not have the mathematical chops to do game programming, and I can't imagine Enterprise C++ apps are any better than Enterprise Java apps.

I guess it also doesn't help that we're basically supporting multiple platforms off the bat, and dealing with all the issues between each system, and that we're also reducing the team in half because we're having to reallocate resources.

Not So Fast posted:

There's a series of books by Steve Meyers (Effective C++ etc.) that collect a bunch of his articles on best practices for using the "new" C++11 features, that are an invaluable extension of just using cppreference or SO.

I'll look into this.. maybe get my employer to buy these books.

Adbot
ADBOT LOVES YOU

Strong Sauce
Jul 2, 2003

You know I am not really your father.





I was thinking alone the lines of Game Engine developers and the like. Maybe they don't get paid that well. I would assume any hedge funds using C++ have probably worse coding standards than Enterprise apps. But I have nothing to go on for that thinking.

Also, if I told you what company I worked at you'd probably say I work in the Games industry. I just don't do anything that involves rendering a triangle onto the screen.

Okay that's it for me. Didn't want to derail this thread too much.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply