What are the #pragma push/pop macros for?
I know what they do, am just not sure why they're needed here - just to avoid clashing with macros of the same name from other headers, or do conflicts somehow happen within that code itself (like when using it with different types)?
I kinda buried the lede yesterday: my next book “Lifehouse: Taking Care of Ourselves in A World On Fire” is finally available for pre-order from Verso! It’s about how we organize ourselves as communities to survive the climate-systems collapse unfolding all around us, drawing on lessons from the Black Panther survival programs, Occupy Sandy and the Crisis-era Greek solidarity clinics straight through to municipalism in Spain and democratic confederalism in Rojava! https://www.versobooks.com/en-gb/products/2536-lifehouse
If you’ve been enjoying our conversations here about the Long Emergency, the #pragma, assembly-based systems of local self-determination, and the #lifehouse itself as a concrete implementation of #solarpunk values and ideas about the world, and as a way of sheltering ourselves against all the storms to come, I genuinely think you’ll find something useful in this book. 👊
Sunday! And that means it’s time for this week’s #Lifehouse thread. Last week we talked about the #pragma; this week I want to cover something that I see as at least as important to the idea of a functioning Lifehouse network or federation, which is the distinction between formal openness and a quality I think of as “invitationality.”
I do not suggest this will be easy, or unvexed by any of the complications that invariably attend human sociality & collective endeavor. But it’s not optional, either. In fact, a large part of the reasoning behind bothering to articulate the idea of the #pragma in the first place is to unlock the invitationality of the Lifehouse as a space & an idea. Each local hub has to be free to vary in its presentation and affects, in order to feel authentically like the effort of the people who make it up.
Every Sunday for the past month or so, I’ve posted threads previewing my forthcoming book “#Lifehouse” for folks who follow me here. A bunch of them asked me to make yesterday’s thread public, so they could share it with friends they thought might have an interest in it, and after some consideration that’s something I’m willing to do. So please enjoy this discussion of one of the ideas in the book I’m most hoping readers find useful: a neat little bit of social technology I call “the #pragma.”
This is a lovely thread from @adamgreenfield. You will (I think) need to request to follow Adam to see it.
The gist is that Adam proposes that progressive left groups use a kind of social analogue of a ‘pragma’ (https://en.wikipedia.org/wiki/Directive_(programming)) as an ‘interface’ that allows them to collaborate (and gain more efficacy in so doing) without descending into factionalism
How does Rust prevent long-running "pointers" from becoming dangling? For example, passing in the instance of some service to something trying to communicate with it; how does it prevent that instance from being destructed & deallocated before that client stops using it?
I tried searching but find only 1200 tutorials on the borrow checker; which IMO cannot do this long-term lifetime check.
@lesley@chandlerc The two main problems remaining are pointer arithmetic, and dangling pointers. Pointer arithmetic I would much prefer to just turn off for nearly all code. Your code should not be doing raw pointer arithmetic. Use standard library types.
But those standard library types have to be able to do so. And yep, I'd make that into a #pragma unsafe or [[unsafe]] or something like that, to allow pointer math inside that area only.
Many years ago when I started using C# I really liked pragma regions, now I just think they add noise to the code and I actively dislike them. I wonder if that's also a result of sometimes the shift between coding styles (more verbose or more simple etc)
@djlink That sounds like Swift’s // MARK: foo and CodeWarrior/Xcode's #pragma mark ?
I like that you can use extensions/categories for that in most modern languages (though I'm sad that Swift did away with named extensions, so they're all just “extension Foo” and not @ interface Foo (AGoodDescription).
And yeah, these days I see the need for // MARK: mostly as a sign that this file should be split up into multiple smaller files.
As much as I like Rust, I'm rather skeeved by (the USA) government's sudden interest in "memory safety" and "open source security" and all that. Yes, we need to fix The Infrastructure(tm). But why did it take 1) having a systems-level memory safe language, 2) for the realization that shit can be pwned if it's not memory safe, 3) while never really doing the "taxes should fund free software infrastructure" bit in the past? We have had free C infra for 30 years. Why until now, top-down?
@federicomena I think it would be really funny if the outcome here was a very rapidly standardized Safety Critical C++ subset (with a "#pragma unsafe" to reenable everything else, because why not? rust has it) and nothing changing
Just proposed a new feature for Cesium, a C to .NET compiler I maintain. This time, I am thinking of adding (an almost) seamless native interop via #pragma pinvoke: https://github.com/ForNeVeR/Cesium/issues/511
I know this is probably a primitive topic for most, but I just got into coding in c++ because a simple project I am working on that uses esp8266 which can be programmed using c++. Before this I only had experiemce with python, javascript and typescript....
Thank you for your explanation! From what I have read ‘#pragma once’ solves the problem with mutiple includes for most modern compilers, but it’s always better to write the import guards for better compatability?
You probably don’t have to worry about the compatability of #pragma once so just use that. The only reasons to not use it is if it’s important to only use standard compliant c for whatever reason or if you need to support some arcane compiler that doesn’t support #pragma once. Realistically, neither of these are situations that you’ll ever be put in and if you are you probably have much larger things that you need to worry about.
What you are seeing is a warning that your compiler may have found a use-after-free bug, but I think this is a false positive. Your build is configured to turn this warning into a hard error.
How to fix it?
I think it will be difficult to know how to fix this without knowing more about your build setup. Are you passing any custom CFLAGS? What compiler and version are you using?
Also, here is someone asking about the same issue (in the same code) on Stack Exchange using GGC 12.1:
Today's gcc bug https://gcc.gnu.org/PR111051 is a case where gcc stopped recognizing some avx2 primitives on avx512 code (all on highway-1.0.6 code again):
Hello there, fellow programmers! I am an Aeronautical Engineering student who is doing research on Multidisciplinary Optimization (MDO) since the beginning of this year....
There are a many approaches to implementing OOP in C. Since C doesn’t give you any language constructs to implement this out of the box, it’s up to you to do it in a consistent and understandable manner. Since there is no definite way to do it, let me just give you an example of how I would translate a Python file, and you can decide how you implement it from there:
Some of my iterations are delightfully recursive (lemmy.world)
Help me understand splitting c++ code into source files and headers
I know this is probably a primitive topic for most, but I just got into coding in c++ because a simple project I am working on that uses esp8266 which can be programmed using c++. Before this I only had experiemce with python, javascript and typescript....
Can't compile "iwlwifi" module in Linux
I’m trying to build iwlwifi module manually and for my needs....
[HELP] From Python OOP to C
Hello there, fellow programmers! I am an Aeronautical Engineering student who is doing research on Multidisciplinary Optimization (MDO) since the beginning of this year....