Doomed_Daniel, to random
@Doomed_Daniel@mastodon.gamedev.place avatar

I'm not sure if everyone shares my fondness for X macros, but I sure like them:
https://github.com/DanielGibson/dhewm3/blob/a0bd8161445462daf6253da3ce9b7eeee5a64c89/neo/sys/sys_imgui.cpp#L516-L886

(that code writes and reads Dear ImGui styles to/from an ini-like text file)

Doomed_Daniel,
@Doomed_Daniel@mastodon.gamedev.place avatar

@pervognsen
oh god :D

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)?

adamgreenfield, to random
@adamgreenfield@social.coop avatar

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

adamgreenfield,
@adamgreenfield@social.coop avatar

If you’ve been enjoying our conversations here about the Long Emergency, the , assembly-based systems of local self-determination, and the itself as a concrete implementation of 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. 👊

adamgreenfield, to random
@adamgreenfield@social.coop avatar

Sunday! And that means it’s time for this week’s thread. Last week we talked about the ; 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.”

adamgreenfield,
@adamgreenfield@social.coop avatar

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 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.

adamgreenfield, to random
@adamgreenfield@social.coop avatar

Every Sunday for the past month or so, I’ve posted threads previewing my forthcoming book “” 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 .”

urlyman, to random
@urlyman@mastodon.social avatar

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

https://social.coop/@adamgreenfield/112111139870536074

adamgreenfield,
@adamgreenfield@social.coop avatar

@urlyman @boud I just reposted the entire thread on Public – search .

dascandy42, to random
@dascandy42@mastodon.social avatar

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.

dascandy42,
@dascandy42@mastodon.social avatar

@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.

djlink, to random
@djlink@mastodon.gamedev.place avatar

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)

uliwitness,
@uliwitness@chaos.social avatar

@djlink That sounds like Swift’s // MARK: foo and CodeWarrior/Xcode's 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.

djlink,
@djlink@mastodon.gamedev.place avatar

@uliwitness yeah it's the

amberxorluci, to random
@amberxorluci@crimew.gay avatar

if you use pragma once you might be entitled to one plate of pasta from me

Vierkantor,
@Vierkantor@mastodon.vierkantor.com avatar

@amberxorluci what if i used #pragma many times?

amberxorluci,
@amberxorluci@crimew.gay avatar

@Vierkantor i mean #pragma once but i'd make you food anyway because you're a friend ^^

federicomena, to random
@federicomena@mstdn.mx avatar

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?

aeva,
@aeva@mastodon.gamedev.place avatar

@federicomena I think it would be really funny if the outcome here was a very rapidly standardized Safety Critical C++ subset (with a " unsafe" to reenable everything else, because why not? rust has it) and nothing changing

fornever, to random
@fornever@dotnet.social avatar

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

FrameXX, to programming in Help me understand splitting c++ code into source files and headers

Thank you for your explanation! From what I have read ‘ once’ solves the problem with mutiple includes for most modern compilers, but it’s always better to write the import guards for better compatability?

zygo_histo_morpheus, to programming in Help me understand splitting c++ code into source files and headers

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.

karolherbst, to random
@karolherbst@chaos.social avatar

all C++ devs will hate you with this little trick: #pragma GCC poison auto

karolherbst, to random
@karolherbst@chaos.social avatar

mad C coding challenge:

insert this in project globally: #pragma GCC poison return

have fun...

cbarrick, (edited ) to programming in Can't compile "iwlwifi" module in Linux

Why is it?

The code hitting that error is here:

git.kernel.org/pub/scm/linux/…/subcmd-util.h

It looks fine to me.

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:

unix.stackexchange.com/…/linux-kernel-5-15-54-com…

This was the top result when Googling linux “-Werror=use-after-free”.

I believe you can disable this warning in this file by adding a pragma after the includes (line 8):


<span style="color:#323232;">#pragma GCC diagnostic ignored "-Wuse-after-free"
</span>

See stackoverflow.com/…/selectively-remove-a-warning-…

Edit: If you don’t want to change the code, try disabling the use-after-free warning from the make call:


<span style="color:#323232;">make CFLAGS="-Wno-use-after-free"
</span>
aeva, to random
@aeva@mastodon.gamedev.place avatar

balls

trofi, to random
@trofi@fosstodon.org avatar

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):

<immintrin.h>

GCC target("avx512vl,avx512dq")

void bug(__m256i i) {
volatile auto v1 = _mm256_cvtepi64_pd(i);
}

and failed as error: inlining failed in call to 'always_inline' '__m256d _mm256_setzero_pd()': target specific option mismatch

foone, to random
@foone@digipres.club avatar

One thing they don't you up front when you get into reverse engineering is how much of your life will be taken up by worrying about stacks

dexitroboper,
@dexitroboper@aus.social avatar

@foone let alone

niss, to random
@niss@chitter.xyz avatar

twice

:oneofthem: :twoofthem:

foone, to random
@foone@digipres.club avatar

arg
two libraries I'm using are colliding on IFDEF names

because both have KEY_H include barriers around their very generically named key.h files

thp,
@thp@dosgame.club avatar

@foone One of the corner cases handled well by using „ once“ instead.

SeaOfTranquility, (edited ) to programming in [HELP] From Python OOP to C
@SeaOfTranquility@beehaw.org avatar

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:

--------------
class Parent:
    def __init__(self, param1: str, param2: int):
        self.__param1 = param1
        self.__param2 = param2
    def __private_method(self):
        print("private method")
    def public_method(self):
        print("public method")
    @staticmethod
    def static_method():
        print("static method")
    @property
    def param1(self):
        return self.__param1

class Child(Parent):
    def __init__(self):
        super().__init__("param1", 2)
--------------

I would split the C code for this into header and source files:

(header.h)

--------------
#pragma once

/// Parent Class ///
typedef struct Parent_obj {
    char* param1
    unsigned int param1_len
    int param2
} Parent_obj_t;
void Parent_init(Parent_obj_t* self, char* param1, unsigned int param1_len, int param2);
void Parent_public_method(Parent_obj_t* self);
void Parent_static_method();
void Parent_param1(Parent_obj_t* self, char* out, unsigned int max_len); // property method with upper bound string length
void Parent_del(Parent_obj_t* self); // destruct object (similar to __del__() in python)

/// Child Class ///
typedef struct Child_obj {
    Parent_hidden_state_t* super
    char* param
    unsigned int param_len
} Child_obj_t
void Child_init(Child_obj_t* self, Parent_obj_t* super);
void Child_del(Child_obj_t* self);
--------------

(source.c)

--------------
#include "header.h"

/// Parent Class ///
// private methods
void Parent_private_method(Parent_obj_t* self){...} // not visible in the header file
// public methods
void Parent_init(Parent_obj_t* self, char* param1, unsigned int param1_len, int param2){...}
void Parent_public_method(Parent_obj_t* self){...}
void Parent_static_method(){...}
void Parent_param1(Parent_obj_t* self, char* out, unsigned int max_len){...}
void Parent_del(Parent_obj_t* self){...}

/// Child Class ///
// public methods
void Child_init(Child_obj_t* self, Parent_obj_t* super){...}
void Child_del(Child_obj_t* self){...}
--------------

Modules and namespaces can be modeled using folders and prefixing your structs and functions.

  • All
  • Subscribed
  • Moderated
  • Favorites
  • megavids
  • thenastyranch
  • magazineikmin
  • osvaldo12
  • GTA5RPClips
  • mdbf
  • Youngstown
  • tacticalgear
  • slotface
  • rosin
  • kavyap
  • ethstaker
  • everett
  • khanakhh
  • JUstTest
  • DreamBathrooms
  • InstantRegret
  • cubers
  • normalnudes
  • Leos
  • ngwrru68w68
  • cisconetworking
  • modclub
  • Durango
  • provamag3
  • anitta
  • tester
  • lostlight
  • All magazines