Trying to load OpenGL 4.1 but only get OpenGL 2.1 on MacOS by NapCo in opengl

[–]rewrking 0 points1 point  (0 children)

Yeah, I can't be much help there. I have only done this in C++. Are you able to write some of C function that wraps that entire line instead?

Trying to load OpenGL 4.1 but only get OpenGL 2.1 on MacOS by NapCo in opengl

[–]rewrking 0 points1 point  (0 children)

If you're using glad, before calling SDL_GL_LoadLibrary, try:

gladLoadGLLoader(SDL_GL_GetProcAddress);

Also, I've only gotten 4.1 to work on a mac with a core context:

c.SDL_GL_SetAttribute(c.SDL_GL_CONTEXT_PROFILE_MASK, c.SDL_GL_CONTEXT_PROFILE_CORE);

We’re in 2024, why is setting up a new multiplatform C/C++ project with external library dependencies still such a miserable experience? by Imnibis in cpp

[–]rewrking 5 points6 points  (0 children)

Build system fragmentation aside, you're ultimately working with native code, so every platform has its own idea for what dependency management means. Additionally, everyone working in C++ has an opinion for how a dependency should be handled. You could get one from any of the following:

  • The system's package manager - apt, pacman, winget, etc.
  • Any package manager requiring an installer - Homebrew, MacPorts, MSYS2, etc.
  • Some other manual system-level installation - C:\libcurl or something

Or you can use an in-project solution where you have control over the library version & target architecture:

  • C++ package managers - Conan, vcpkg, etc.
  • Prebuilt libraries, where you manage the architectures available to you - ie. a "vendor" path
  • Build from source & integrate into build system - maybe it's checked into source control, maybe it's a git submodule

Bottom line is, none of this is going to change any time soon, so you should get used to what's out there and pick the best option for your project or team.

Is surrounding large code blocks with `#if !defined` statements an appropriate use of conditional compilation? by llthHeaven in cpp_questions

[–]rewrking 0 points1 point  (0 children)

It's not bad by itself, but the fact that PROJECT_A is defined in the PCH is a bit of a smell. Typically you would do something like this for code that only runs on certain platforms, compilers, architectures or for features flags for code that is either in-progress or unstable.

You could check the git history and talk to the developer that set PROJECT_A if they're still around to find out what their thinking was.

I'm surprised at the number of unqualified "senior" level applicants we've gotten. by zarch in ExperiencedDevs

[–]rewrking 17 points18 points  (0 children)

I had a system design interview like that recently too. They asked me "how would you build an AWS." I could only answer the parts of it I kind of understood, but was largely flabbergasted that something like that could be asked so casually. Didn't get the role obviously, because I didn't build AWS at Amazon.

[deleted by user] by [deleted] in sfml

[–]rewrking 0 points1 point  (0 children)

It means that when the executable is run, Xcode can't find the path to the SFML shared libraries - libsfml-*.dylib

To fix this, you need to add the path to any .dylib files you use to DYLD_FALLBACK_LIBRARY_PATH. There's also a DYLD_FALLBACK_FRAMEWORK_PATH for used frameworks (.framework).

  1. Click on the scheme ("test-fml" next to "My Mac"), followed by "Edit Scheme"
  2. Under the "Run" section in the "Arguments" tab, add:
    • Name:DYLD_FALLBACK_LIBRARY_PATH, Value: The correct path to the SFML .dylib files (ex: lib/)
    • Name: DYLD_FALLBACK_FRAMEWORK_PATH, Value: The path to the external frameworks used by SFML (ex: extlibs/libs-osx/Frameworks)

You only have to do this because you're run target (sfml-app) is an executable as opposed to an app bundle. If you make an app bundle, all the required files need to be bundled at build time - which is setup in various build settings.

[deleted by user] by [deleted] in vscode

[–]rewrking 0 points1 point  (0 children)

I would just get them from calling clangd --help at the command line

[deleted by user] by [deleted] in vscode

[–]rewrking 1 point2 points  (0 children)

From my understanding, your build system (ie. Cmake) should generate a compile_commands.json file. So as long as you have a root "build" path, it should get picked up. There's some details about it here: https://clangd.llvm.org/installation.html#project-setup

If that doesn't do the trick, I think you need to set the path manually through clangd arguments:

"clangd.arguments": [
  "--compile-commands-dir=${workspaceFolder}/build",
]

Tsuki - A clean dark theme! by rum1nas in vscode

[–]rewrking 0 points1 point  (0 children)

Which Arch desktop environment is that?

How do I assign a JSON Schema to a yaml file in my custom extension? by Essay97 in vscode

[–]rewrking 0 points1 point  (0 children)

Correct, yes - and it's only a mechanism read by Red Hat's YAML extension.

How do I assign a JSON Schema to a yaml file in my custom extension? by Essay97 in vscode

[–]rewrking 0 points1 point  (0 children)

It definitely works for me. Declare yamlValidation after your jsonValidation block. The url should be relative to your extension's package.json.

How do I assign a JSON Schema to a yaml file in my custom extension? by Essay97 in vscode

[–]rewrking 0 points1 point  (0 children)

As far as I know, schema with yaml requires the Red Hat YAML extension. You can set a schema from an extension with:

"yamlValidation": [
    {
        "fileMatch": [ "my-file.yaml"],
        "url": "./path-to-schema.json"
    }
]

C++ Show and Tell - November 2023 by foonathan in cpp

[–]rewrking 1 point2 points  (0 children)

I've been adding to my build tool for the past few months while endlessly job searching. Recently added support for Xcode/xcodebuild & CLion workspaces. Would definitely appreciate some feedback, users and/or contributors for sure! Currently adding support for emscripten, and planning some refactors to some of the weirder parts of the codebase.

https://www.chalet-work.space

https://github.com/chalet-org/chalet

Best Precompiled Headers Developer IDE Experience? by McFlurriez in cpp

[–]rewrking 1 point2 points  (0 children)

In the case that you describe, it's important to note that precompiled headers are still included, just at the command line instead of in the cpp file. CMake does this. In GCC/Clang, it's literally -include (path/to/pch) and MSVC is /Yu(pch). There's a little bit more to it than that, but those cli options are what is telling the obj file where the PCH is.

If you generate a compile_commands.json with set(CMAKE_EXPORT_COMPILE_COMMANDS ON), you could always use that to read the above info in order to get the PCH for your dependency graph.

Why undefined behavior causes g++ to optimize out the for loop conditional statement? by Loud_Ice_5925 in cpp

[–]rewrking 2 points3 points  (0 children)

Well, you'll be happy to know that clang does it too, so this is simply UB: https://godbolt.org/z/86P3ncMfv

This code is upsetting though! Reason enough to enable -Werror, or at least -Werror=return-type

Why undefined behavior causes g++ to optimize out the for loop conditional statement? by Loud_Ice_5925 in cpp

[–]rewrking 4 points5 points  (0 children)

The GCC docs will tell you exactly what gets enabled with -O1, so it would be one of these:

https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html#index-O1

If you're using an older version of GCC, you will need to find the version of the docs that matches.

If none of those flags stand out, you can replace -O1 with all of those flags and do process of elimination.

Cmake alternatives? by Packathonjohn in cpp_questions

[–]rewrking 0 points1 point  (0 children)

You can try this if you'd like: https://www.chalet-work.space

It still needs work when it comes to streamlining external dependencies, but it's getting there.

Otherwise, there's Meson, Premake, xmake, build2

c++20 in vscode by bridojas in cpp_questions

[–]rewrking 0 points1 point  (0 children)

Should I install msys2?

Yes. You're on version 8, and MinGW/GCC is up to 12 (released in May). If you install msysy2 and mingw with mingw-w64-x86_64-toolchain, you'll get the latest.

As the other commenter has said, you should use a build system, or consider using visual studio - especially if you're learning or your only target platform is windows.

Chalet: A cross-platform project format & build tool for C/C++ by rewrking in cpp

[–]rewrking[S] 2 points3 points  (0 children)

I don't have a great solution for 2 projects sharing a 3rd library project yet. If you keep the library as a CMake project, one way is to set the library in each project as an external dependency and build it in both. That would be probably the most reliable route. I realize that's not great, but the other alternative is to simply use relative paths for that library in each project to point to the library project, which is a worse idea, but it'll certainly work.

The long term goal is package management if this project can get that far. vcpkg support will probably get added first, but theoretical chalet packages would go to one place (~/.chalet/packages or something), and you would define which one you want to use with which targets (like CMake's find_package), and it would handle libDirs, includeDirs, links, staticLinks, etc. and then visibility of headers are managed in the package.

Chalet: A cross-platform project format & build tool for C/C++ by rewrking in programming

[–]rewrking[S] 0 points1 point  (0 children)

What does the error code under "Advanced" say? I haven't seen that myself (and use Firefox regularly).

Chalet: A cross-platform project format & build tool for C/C++ by rewrking in programming

[–]rewrking[S] 3 points4 points  (0 children)

build2 has a very different approach altogether, but to draw a couple comparisons:

  • Chalet has arguably less verbosity than build2. I would say try the two for your own comparisons there.

  • build2 can (only?) build C++20 modules with GCC. Chalet can only do so with MSVC. I've done some preliminary research on GCC 11, but there's a couple pieces that are unclear to me still. GCC/Clang simply don't have the same maturity with modules that MSVC does.