Best Practice for testing Managed Buffers?
On Macs with discrete graphics cards, Managed buffers should be used instead of Shared Buffers, however there are additional requirements to maintain synchronisation using...
View ArticleAnswer by trojanfoe for Can we implement metal framework in CPP
Apple provide metal-cpp which provides direct access to the Metal API from C++. One downside appears to be that manual reference counting must be used, like the bad old days. This is probably not much...
View ArticleAnswer by trojanfoe for Is there any possibility of using C++ directly with...
Yes! Apple now provide an official Metal C++ wrapper.This download also provides C++ wrappers for some Foundation and QuartzCore classes as well, however it's not obvious how you are supposed to...
View ArticleAnswer by trojanfoe for how can i tell which dylibs are loaded when debugging...
From the debugger console, when the app is paused, you can use:image listFrom the command line you can use:$ otool -L /path/to/executable
View ArticleAnswer by trojanfoe for Xcode 5 how to Linking Dynamic Libraries from App Bundle
Content/Libraries is not a standard directory within an app bundle; use Contents/Frameworks instead (.dylibs are allowed in that directory just the same as .frameworks).Set the Install Name of each...
View ArticleAnswer by trojanfoe for How do I remove / hide source control notifications...
This Count Badge setting should do the trick:
View ArticleAnswer by trojanfoe for port command not found
You need /opt/local/bin in the $PATH.To add to $PATH:export PATH=/opt/local/bin:$PATH
View ArticleAnswer by trojanfoe for sending an email from a C/C++ program in linux
You could invoke your local MTA directly using popen() and feed it RFC822-compliant text.#include <stdio.h>#include <string.h>#include <errno.h>int sendmail(const char *to, const char...
View ArticleAnswer by trojanfoe for Dev-C++: 'prinft' undeclared
Typo:prinft()should be:printf()printf is short for "print formatted".
View ArticleAnswer by trojanfoe for Dependency fails to compile in workspace but not in...
@kmdreko is correct in that you need:resolver = "2"in the workspace Cargo.toml file as described in the beginner's guide.
View ArticleAnswer by trojanfoe for install_name_tool difference between -change and -id
Install NameThe term install name refers to the exact path of the .dylib file in the end-user system so the runtime linker can find and load the dynamic library.The name can be either:Absolute, which...
View ArticleAnswer by trojanfoe for Does "-dndebug" (lowercase) do anything in g++?
It's fairly easy to test:Test program test.cpp#include <iostream>int main(){#ifdef TEST_DEFINE std::cout << "defined" << std::endl;#endif return 0;}Result$ g++ -o 1 -DTEST_DEFINE...
View ArticleAnswer by trojanfoe for Is there a way to obtain the output of a linux...
You want popen(). Here's an example, taken from... (see below).void get_popen_data() { FILE *pf; char command[COMMAND_LEN]; char data[DATA_SIZE]; // Execute a process listing sprintf(command, "ps aux...
View ArticleAnswer by trojanfoe for How do I tell CMake to use Clang on Windows?
As an update for Visual Studio 2019 and 2022, you can install the clang-cl toolchain via the Visual Studio Installer and use this to generate a .sln file:> mkdir build && cd build> cmake...
View ArticleAnswer by trojanfoe for clang format: disable ordering includes
With more recent versions of clang-format it seems you need both:IncludeBlocks: PreserveSortIncludes: Never
View ArticleWill this RAII-style Objective-C class work?
Under C++, I have a Mutex class, and I use this RAII-style class to ensure the mutex is unlocked, regardless of the reason for the method return:class MutexLock {protected: Mutex &m_mutex;public:...
View ArticleAnswer by trojanfoe for Filling Buffer with Elements of Different Lengths...
Probably not what you’re looking for, but if I was approaching this problem I would be tempted to build a linked list of pointers to the elements first and have a function to flatten the list out into...
View ArticleAnswer by trojanfoe for XcodeCloud build fails with "The ci_pre_xcodebuild.sh...
You have violations in your swift code and that's how swiftlint is telling you. It should be outputting those violations to the console so you can see what they are.Also cd .. is weak; use something...
View ArticleAnswer by trojanfoe for How to create VStack within HStack with equal element...
I think you want scaledToFill() on both the VStack and the HStack:HStack(alignment: .center, spacing: 0) { ForEach(0...6, id: \.self) { _ in VStack(alignment: .center) { Text("T") } .frame(maxWidth:...
View ArticleAnswer by trojanfoe for How to create a view that can display multiple objects?
How about this?protocol ItemProtocol { func name() -> String func description() -> String func optionalThing() -> String?}struct Item1: ItemProtocol { var n: String var d: String var t: String...
View ArticleAnswer by trojanfoe for how to convert optional decimal type to String in swift
If you cast the conversion to Any, then that will work because the compiler is happy that either Decimal or String can used:import Foundationlet iAmNil: Decimal? = nillet iAmDecimal: Decimal? =...
View ArticleAnswer by trojanfoe for Optionally reference parent struct
You need to specify the life time of the reference to the parent. Something like this:use std::collections::HashMap;#[derive(Debug)]struct Value { _value: String,}impl Value { fn new(value: &str)...
View ArticleAnswer by trojanfoe for Immutable HashMap with mutable object as value
You will need to use interior mutability:use std::{cell::RefCell, rc::Rc, collections::HashMap};fn main() { let aa = HashMap::from([(1, Rc::new(RefCell::new(1)))]); println!("{:?}",aa); if let...
View ArticleAnswer by trojanfoe for CC crate example won't link with the C functions
The build.rs file needs to be in the top-level directory, next to Cargo.toml, and not in the src directory.Also note that you have an error in foo.c:printf("this is foo\n");
View ArticleComment by trojanfoe on How do I suppress this Xcode static analyzer warning?
@l'L'l The Xcode static analyser seems to use different flags to the normal compiler warnings. It doesn't appear to have any inline way of suppressing warnings you have no control over; I've spent a...
View ArticleAnswer by trojanfoe for Xcode - How to run script just before build starts
The best approach is to create pseudo target in your project.For example, say you have a shell script that sets the app version by updating an .xcconfig file:Create a target called SetAppVersion of...
View ArticleAnswer by trojanfoe for Redeclaring a variable causes calculation errors
Assuming there is a return dMetalFrameR; at the end of that function, then the result is always 0.0 because that variable is never changed from its initial value.This, incorrect, code:double...
View ArticleAnswer by trojanfoe for Share Android Studio SDKs and projects between users...
By default Android Studio will want the Android SDK to be in $HOME/Library/Android/sdk. This can be changed to whatever you like, for example /Users/Shared/Library/Android/sdk from within Android...
View ArticleAnswer by trojanfoe for C: Which character should be used for ptrdiff_t in...
It's %td. See here or better still here.
View ArticleComment by trojanfoe on Why is my notarized and signed macOS .dmg rejected by...
Won't you need to sign it with an Installer certificate?
View ArticleComment by trojanfoe on My Comfyui running through Homebrew on my Intel Mac...
Are you certain that ComfyUI is running the same python as you run when invoking python3. If it's anything like my experience with Stable Diffusion on Linux, then I have to build my own Python 3.10 in...
View ArticleComment by trojanfoe on How to run an Xcode app via the terminal?
If you want to use the terminal then don't use Xcode. Instead use vscode/zed/clion/neovim along with cmake.
View ArticleComment by trojanfoe on symbol(s) not found for architecture arm64 in my own...
I assume hello() is defined in library.c, which you are not compiling or linking into the program by the look of it.
View ArticleComment by trojanfoe on How to privately link a library to an external static...
If both library A and library B are static then you must specify them both in the final linker command line, regardless of whether you are linking a dynamic library or an executable.
View ArticleComment by trojanfoe on Client freezes on recv despite server confirming data...
^^^ Which is often done by prepending the payload length (typically in big-endian format) at the start of the message ^^^
View ArticleAnswer by trojanfoe for How to use metal-cpp with GLFW?
Yes it's certainly possible. Here's an example I just put together.It uses Apple's unsupported metal-cpp-extensions code in order to set-up the CAMetalLayer in the NSWindow's view, and I had to modify...
View ArticleComment by trojanfoe on SDL3 CMake linkage problem undefined reference for SDL
I don't know if you are still interested in this, but you don't have a find_package(SDL3 REQUIRED) statement. Better is to use CPM for cmake dependencies.
View ArticleComment by trojanfoe on Set include directory for linker (ld) on OSX
@EatonEmmerich You should start a new question.
View ArticleComment by trojanfoe on Mac Apache giving 403 Forbidden on Users directory
What does the apache error logs tell you?
View ArticleComment by trojanfoe on How do I update my c++ version on a Mac M2
Clang 16.0 can support C++20, so it's just a case of passing -std=c++20 to the compiler. Use cmake to curate your project, which will allow you to use Xcode, Visual Studio, CLion, VSCode, Zed, etc.
View ArticleComment by trojanfoe on Problem with SDL2 + game controllers: too many open...
The process limit for open files on macOS is something like 10240, so if you are exceeding that it would point to a file handle leak in your program. Double check any code that opens a file that the...
View ArticleComment by trojanfoe on After launch Virtualbox nothing happens
This is not a programming question. Try apple.stackexchange.com
View Article