home.social

#define — Public Fediverse posts

Live and recent posts from across the Fediverse tagged #define, aggregated by home.social.

  1. @brouhaha @aeva We're not stopping for constexpr, we have #define at home :-P

  2. @regehr @ricci @atsuzaki why don’t they just add the #define s. How are they still finding undefined stuff

  3. <built-in>:40:32: error: source file is not valid UTF-8
    40 | #define __VERSION__ "Clang 21.1.1"
    | ^

    thanks clang ??

  4. Okay, macro approach blows everything else out of the water, catching all narrowing conversions at the type level. I don't think I can use it for the `mke_u16` (make, but report errors) variant without getting a little clever/hybrid about it, but the hybrid approach actually does work.

    ```
    typedef int err_t; // For snippetware purposes

    // Secret inner thing with underscore
    static inline err_t _mke_u16(u16 *dest, u16 src) {
    *dest = src;
    return 0;
    }

    // Actual API
    #define mke_u16(dest, v) _mke_u16(dest, u16{v})

    int main() {
    err_t err;
    u16 dest;
    err = mke_u16(&dest, 5); // Correct, works
    err = mke_u16(&dest, -4); // Incorrect, caught
    err = mke_u16(&dest, 0xFFFF1); // Incorrect, caught

    uint16_t srcA = 0xFFFF;
    err = mke_u16(&dest, srcA); // Correct, works

    uint32_t srcB = 0x1; // Fine value, bad type
    err = mke_u16(&dest, srcB); // Incorrect, caught
    return err;
    }
    ```

    This, of course, raises the question what an API consumer would use `mke_u16` *for*.

  5. RE: social.vivaldi.net/@lproven/11

    isso aqui me pegou

    #define IF if(
    #define THEN ){
    #define ELSE } else {
    #define ELIF } else if (
    #define FI ;}

    #define BEGIN {
    #define END }
    #define SWITCH switch(
    #define IN ){
    #define ENDSW }
    #define FOR for(
    #define WHILE while(
    #define DO ){
    #define OD ;}
    #define REP do_lbr
    #define PER }while(
    #define DONE );
    #define LOOP for(;;){
    #define POOL }

  6. RE: social.vivaldi.net/@lproven/11

    isso aqui me pegou

    #define IF if(
    #define THEN ){
    #define ELSE } else {
    #define ELIF } else if (
    #define FI ;}

    #define BEGIN {
    #define END }
    #define SWITCH switch(
    #define IN ){
    #define ENDSW }
    #define FOR for(
    #define WHILE while(
    #define DO ){
    #define OD ;}
    #define REP do_lbr
    #define PER }while(
    #define DONE );
    #define LOOP for(;;){
    #define POOL }

  7. RE: social.vivaldi.net/@lproven/11

    isso aqui me pegou

    #define IF if(
    #define THEN ){
    #define ELSE } else {
    #define ELIF } else if (
    #define FI ;}

    #define BEGIN {
    #define END }
    #define SWITCH switch(
    #define IN ){
    #define ENDSW }
    #define FOR for(
    #define WHILE while(
    #define DO ){
    #define OD ;}
    #define REP do_lbr
    #define PER }while(
    #define DONE );
    #define LOOP for(;;){
    #define POOL }

  8. RE: social.vivaldi.net/@lproven/11

    isso aqui me pegou

    #define IF if(
    #define THEN ){
    #define ELSE } else {
    #define ELIF } else if (
    #define FI ;}

    #define BEGIN {
    #define END }
    #define SWITCH switch(
    #define IN ){
    #define ENDSW }
    #define FOR for(
    #define WHILE while(
    #define DO ){
    #define OD ;}
    #define REP do_lbr
    #define PER }while(
    #define DONE );
    #define LOOP for(;;){
    #define POOL }

  9. RE: social.vivaldi.net/@lproven/11

    isso aqui me pegou

    #define IF if(
    #define THEN ){
    #define ELSE } else {
    #define ELIF } else if (
    #define FI ;}

    #define BEGIN {
    #define END }
    #define SWITCH switch(
    #define IN ){
    #define ENDSW }
    #define FOR for(
    #define WHILE while(
    #define DO ){
    #define OD ;}
    #define REP do_lbr
    #define PER }while(
    #define DONE );
    #define LOOP for(;;){
    #define POOL }

  10. 防御型空母て何? What is a defensive aircraft carrier?
    防御型空母。日本では空母保有を巡って、議論が、一応''なさられてる''一応。
    Defensive aircraft carrier. In Japan, there is some discussion about having an aircraft carrier.

    pixiv.net/novel/show.php?id=20

    #japan #reality #like #define #international #support #problem #attack #scope #distance #understand #aircraft #enemy #limit #introduce #various #carrier #proposal #rescue #counterattack #missions #restrictions #defensive #territorial

  11. 防御型空母て何? What is a defensive aircraft carrier?
    防御型空母。日本では空母保有を巡って、議論が、一応''なさられてる''一応。
    Defensive aircraft carrier. In Japan, there is some discussion about having an aircraft carrier.

    pixiv.net/novel/show.php?id=20

    #japan #reality #like #define #international #support #problem #attack #scope #distance #understand #aircraft #enemy #limit #introduce #various #carrier #proposal #rescue #counterattack #missions #restrictions #defensive #territorial

  12. 防御型空母て何? What is a defensive aircraft carrier?
    防御型空母。日本では空母保有を巡って、議論が、一応''なさられてる''一応。
    Defensive aircraft carrier. In Japan, there is some discussion about having an aircraft carrier.

    pixiv.net/novel/show.php?id=20

    #japan #reality #like #define #international #support #problem #attack #scope #distance #understand #aircraft #enemy #limit #introduce #various #carrier #proposal #rescue #counterattack #missions #restrictions #defensive #territorial

  13. 防御型空母て何? What is a defensive aircraft carrier?
    防御型空母。日本では空母保有を巡って、議論が、一応''なさられてる''一応。
    Defensive aircraft carrier. In Japan, there is some discussion about having an aircraft carrier.

    pixiv.net/novel/show.php?id=20

    #japan #reality #like #define #international #support #problem #attack #scope #distance #understand #aircraft #enemy #limit #introduce #various #carrier #proposal #rescue #counterattack #missions #restrictions #defensive #territorial

  14. 防御型空母て何? What is a defensive aircraft carrier?
    防御型空母。日本では空母保有を巡って、議論が、一応''なさられてる''一応。
    Defensive aircraft carrier. In Japan, there is some discussion about having an aircraft carrier.

    pixiv.net/novel/show.php?id=20

    #japan #reality #like #define #international #support #problem #attack #scope #distance #understand #aircraft #enemy #limit #introduce #various #carrier #proposal #rescue #counterattack #missions #restrictions #defensive #territorial

  15. 防御型空母て何? What is a defensive aircraft carrier?
    防御型空母。日本では空母保有を巡って、議論が、一応''なさられてる''一応。
    Defensive aircraft carrier. In Japan, there is some discussion about having an aircraft carrier.

    pixiv.net/novel/show.php?id=20

    #japan #reality #like #define #international #support #problem #attack #scope #distance #understand #aircraft #enemy #limit #introduce #various #carrier #proposal #rescue #counterattack #missions #restrictions #defensive #territorial

  16. some punk 31 years ago was tired of dealing with "correctly matching const char* vs char*" so they just did

    #define CONST

    and now it's my problem

  17. some punk 31 years ago was tired of dealing with "correctly matching const char* vs char*" so they just did

    #define CONST

    and now it's my problem

  18. some punk 31 years ago was tired of dealing with "correctly matching const char* vs char*" so they just did

    #define CONST

    and now it's my problem

  19. some punk 31 years ago was tired of dealing with "correctly matching const char* vs char*" so they just did

    #define CONST

    and now it's my problem

  20. some punk 31 years ago was tired of dealing with "correctly matching const char* vs char*" so they just did

    #define CONST

    and now it's my problem

  21. So the whole point of the current "regularization" initiative is, instead of optimizing the compressability of the source code, I'm optimizing for compressability of the *model in the programmer's head.*

    I shouldn't need to remember all the time that I can make a short literal number as a compile-time constant with `PRN_ITEXT("3")`. I should be able to look in `mk.h` (the object construction header) and see:

    ```
    // Regular versions must be 255 chars or less.
    // Constant versions must be 7 chars or less.
    /* ... */
    #define PRN_MK_LITNUM(s) ...
    ```

    Oh cool! A way to make a compile-time constant number literal object without thinking about how it works, and I knew just where to look to refresh my memory! Spiffing!

    This isn't to say that the programming model should hide these internal symmetries. I don't think that's healthy. The point is that you can see them when you need to, but ignore them the other 90% of the time. THAT's healthy.

  22. So the whole point of the current "regularization" initiative is, instead of optimizing the compressability of the source code, I'm optimizing for compressability of the *model in the programmer's head.*

    I shouldn't need to remember all the time that I can make a short literal number as a compile-time constant with `PRN_ITEXT("3")`. I should be able to look in `mk.h` (the object construction header) and see:

    ```
    // Regular versions must be 255 chars or less.
    // Constant versions must be 7 chars or less.
    /* ... */
    #define PRN_MK_LITNUM(s) ...
    ```

    Oh cool! A way to make a compile-time constant number literal object without thinking about how it works, and I knew just where to look to refresh my memory! Spiffing!

    This isn't to say that the programming model should hide these internal symmetries. I don't think that's healthy. The point is that you can see them when you need to, but ignore them the other 90% of the time. THAT's healthy.

  23. So the whole point of the current "regularization" initiative is, instead of optimizing the compressability of the source code, I'm optimizing for compressability of the *model in the programmer's head.*

    I shouldn't need to remember all the time that I can make a short literal number as a compile-time constant with `PRN_ITEXT("3")`. I should be able to look in `mk.h` (the object construction header) and see:

    ```
    // Regular versions must be 255 chars or less.
    // Constant versions must be 7 chars or less.
    /* ... */
    #define PRN_MK_LITNUM(s) ...
    ```

    Oh cool! A way to make a compile-time constant number literal object without thinking about how it works, and I knew just where to look to refresh my memory! Spiffing!

    This isn't to say that the programming model should hide these internal symmetries. I don't think that's healthy. The point is that you can see them when you need to, but ignore them the other 90% of the time. THAT's healthy.

  24. So the whole point of the current "regularization" initiative is, instead of optimizing the compressability of the source code, I'm optimizing for compressability of the *model in the programmer's head.*

    I shouldn't need to remember all the time that I can make a short literal number as a compile-time constant with `PRN_ITEXT("3")`. I should be able to look in `mk.h` (the object construction header) and see:

    ```
    // Regular versions must be 255 chars or less.
    // Constant versions must be 7 chars or less.
    /* ... */
    #define PRN_MK_LITNUM(s) ...
    ```

    Oh cool! A way to make a compile-time constant number literal object without thinking about how it works, and I knew just where to look to refresh my memory! Spiffing!

    This isn't to say that the programming model should hide these internal symmetries. I don't think that's healthy. The point is that you can see them when you need to, but ignore them the other 90% of the time. THAT's healthy.

  25. So the whole point of the current "regularization" initiative is, instead of optimizing the compressability of the source code, I'm optimizing for compressability of the *model in the programmer's head.*

    I shouldn't need to remember all the time that I can make a short literal number as a compile-time constant with `PRN_ITEXT("3")`. I should be able to look in `mk.h` (the object construction header) and see:

    ```
    // Regular versions must be 255 chars or less.
    // Constant versions must be 7 chars or less.
    /* ... */
    #define PRN_MK_LITNUM(s) ...
    ```

    Oh cool! A way to make a compile-time constant number literal object without thinking about how it works, and I knew just where to look to refresh my memory! Spiffing!

    This isn't to say that the programming model should hide these internal symmetries. I don't think that's healthy. The point is that you can see them when you need to, but ignore them the other 90% of the time. THAT's healthy.

  26. Update: I've fully figured out the repeatable pattern I want to use for object construction functions in #pronelang. Each object has at least the following four regular functions. Assume that the `...` are always the same consistent args which are sensible for type foo.

    ```
    // Attempt to make a foo and return an error value (an enum where 0 = OK).
    err_t mke_foo(foo_t *dest, ...);

    // Run mke_foo, assert on the err_t, return the result.
    foo_t mk_foo(...);

    // Return a DV of a new foo, or an error atom on failure.
    dv_t mkde_foo(...);

    // Return a DV of a new foo. Asserts on error.
    dv_t mkd_foo(...);

    // Optional: compile-time construction logic.
    #define MKD_FOO(...) /* impl */
    #define MK_FOO(...) /* impl */
    ```

    Unwrappy variants are given ergonomic priority since most callsites can be statically known (to human reviewers) to be infallible. I've implemented everything but the optional macros for atoms, and I'm using naive non-inline functions for now since I'm not in an optimization sprint.

  27. Update: I've fully figured out the repeatable pattern I want to use for object construction functions in #pronelang. Each object has at least the following four regular functions. Assume that the `...` are always the same consistent args which are sensible for type foo.

    ```
    // Attempt to make a foo and return an error value (an enum where 0 = OK).
    err_t mke_foo(foo_t *dest, ...);

    // Run mke_foo, assert on the err_t, return the result.
    foo_t mk_foo(...);

    // Return a DV of a new foo, or an error atom on failure.
    dv_t mkde_foo(...);

    // Return a DV of a new foo. Asserts on error.
    dv_t mkd_foo(...);

    // Optional: compile-time construction logic.
    #define MKD_FOO(...) /* impl */
    #define MK_FOO(...) /* impl */
    ```

    Unwrappy variants are given ergonomic priority since most callsites can be statically known (to human reviewers) to be infallible. I've implemented everything but the optional macros for atoms, and I'm using naive non-inline functions for now since I'm not in an optimization sprint.

  28. Update: I've fully figured out the repeatable pattern I want to use for object construction functions in #pronelang. Each object has at least the following four regular functions. Assume that the `...` are always the same consistent args which are sensible for type foo.

    ```
    // Attempt to make a foo and return an error value (an enum where 0 = OK).
    err_t mke_foo(foo_t *dest, ...);

    // Run mke_foo, assert on the err_t, return the result.
    foo_t mk_foo(...);

    // Return a DV of a new foo, or an error atom on failure.
    dv_t mkde_foo(...);

    // Return a DV of a new foo. Asserts on error.
    dv_t mkd_foo(...);

    // Optional: compile-time construction logic.
    #define MKD_FOO(...) /* impl */
    #define MK_FOO(...) /* impl */
    ```

    Unwrappy variants are given ergonomic priority since most callsites can be statically known (to human reviewers) to be infallible. I've implemented everything but the optional macros for atoms, and I'm using naive non-inline functions for now since I'm not in an optimization sprint.

  29. Update: I've fully figured out the repeatable pattern I want to use for object construction functions in #pronelang. Each object has at least the following four regular functions. Assume that the `...` are always the same consistent args which are sensible for type foo.

    ```
    // Attempt to make a foo and return an error value (an enum where 0 = OK).
    err_t mke_foo(foo_t *dest, ...);

    // Run mke_foo, assert on the err_t, return the result.
    foo_t mk_foo(...);

    // Return a DV of a new foo, or an error atom on failure.
    dv_t mkde_foo(...);

    // Return a DV of a new foo. Asserts on error.
    dv_t mkd_foo(...);

    // Optional: compile-time construction logic.
    #define MKD_FOO(...) /* impl */
    #define MK_FOO(...) /* impl */
    ```

    Unwrappy variants are given ergonomic priority since most callsites can be statically known (to human reviewers) to be infallible. I've implemented everything but the optional macros for atoms, and I'm using naive non-inline functions for now since I'm not in an optimization sprint.

  30. @ska I dunno, it's there on all my machines:

    phendrana:~ eureka% cpp -dM /usr/include/errno.h | grep EREMOTEIO
    #define EREMOTEIO 121

    @khm's explanation of a short read makes sense, but I don't see how that's possible in this environment. it's a qemu-kvm instance, the drive is virtio-blk-scsi backed by LVM with no IO errors on the host reported (or in qemu logs). nothing in the guest kernel logs either. I might understand it if the guest filesystem were damaged and it was a *read* but on a *write* ?

  31. @ska I dunno, it's there on all my machines:

    phendrana:~ eureka% cpp -dM /usr/include/errno.h | grep EREMOTEIO
    #define EREMOTEIO 121

    @khm's explanation of a short read makes sense, but I don't see how that's possible in this environment. it's a qemu-kvm instance, the drive is virtio-blk-scsi backed by LVM with no IO errors on the host reported (or in qemu logs). nothing in the guest kernel logs either. I might understand it if the guest filesystem were damaged and it was a *read* but on a *write* ?

  32. @ska I dunno, it's there on all my machines:

    phendrana:~ eureka% cpp -dM /usr/include/errno.h | grep EREMOTEIO
    #define EREMOTEIO 121

    @khm's explanation of a short read makes sense, but I don't see how that's possible in this environment. it's a qemu-kvm instance, the drive is virtio-blk-scsi backed by LVM with no IO errors on the host reported (or in qemu logs). nothing in the guest kernel logs either. I might understand it if the guest filesystem were damaged and it was a *read* but on a *write* ?

  33. @ska I dunno, it's there on all my machines:

    phendrana:~ eureka% cpp -dM /usr/include/errno.h | grep EREMOTEIO
    #define EREMOTEIO 121

    @khm's explanation of a short read makes sense, but I don't see how that's possible in this environment. it's a qemu-kvm instance, the drive is virtio-blk-scsi backed by LVM with no IO errors on the host reported (or in qemu logs). nothing in the guest kernel logs either. I might understand it if the guest filesystem were damaged and it was a *read* but on a *write* ?

  34. @ska I dunno, it's there on all my machines:

    phendrana:~ eureka% cpp -dM /usr/include/errno.h | grep EREMOTEIO
    #define EREMOTEIO 121

    @khm's explanation of a short read makes sense, but I don't see how that's possible in this environment. it's a qemu-kvm instance, the drive is virtio-blk-scsi backed by LVM with no IO errors on the host reported (or in qemu logs). nothing in the guest kernel logs either. I might understand it if the guest filesystem were damaged and it was a *read* but on a *write* ?

  35. @AminiAllight @kieraaa

    It's a bit annoying that the version macro was not there from the beginning. If you don't ship an openxr.h with your source code, I'd recommend putting something like this in your code:

    ```
    #ifndef XR_API_VERSION_1_0
    #define XR_API_VERSION_1_0 XR_MAKE_VERSION(1, 0, XR_VERSION_PATCH(XR_CURRENT_API_VERSION))
    #endif
    ```

  36. @AminiAllight @kieraaa

    It's a bit annoying that the version macro was not there from the beginning. If you don't ship an openxr.h with your source code, I'd recommend putting something like this in your code:

    ```
    #ifndef XR_API_VERSION_1_0
    #define XR_API_VERSION_1_0 XR_MAKE_VERSION(1, 0, XR_VERSION_PATCH(XR_CURRENT_API_VERSION))
    #endif
    ```

  37. @AminiAllight @kieraaa

    It's a bit annoying that the version macro was not there from the beginning. If you don't ship an openxr.h with your source code, I'd recommend putting something like this in your code:

    ```
    #ifndef XR_API_VERSION_1_0
    #define XR_API_VERSION_1_0 XR_MAKE_VERSION(1, 0, XR_VERSION_PATCH(XR_CURRENT_API_VERSION))
    #endif
    ```

  38. @AminiAllight @kieraaa

    It's a bit annoying that the version macro was not there from the beginning. If you don't ship an openxr.h with your source code, I'd recommend putting something like this in your code:

    ```
    #ifndef XR_API_VERSION_1_0
    #define XR_API_VERSION_1_0 XR_MAKE_VERSION(1, 0, XR_VERSION_PATCH(XR_CURRENT_API_VERSION))
    #endif
    ```

  39. @AminiAllight @kieraaa

    It's a bit annoying that the version macro was not there from the beginning. If you don't ship an openxr.h with your source code, I'd recommend putting something like this in your code:

    ```
    #ifndef XR_API_VERSION_1_0
    #define XR_API_VERSION_1_0 XR_MAKE_VERSION(1, 0, XR_VERSION_PATCH(XR_CURRENT_API_VERSION))
    #endif
    ```

  40. What's pretty neat is that I have wesl-lang.dev with its module system now! That means I can trivially consume lygia.xyz now :)

    I'm also finding some interesting metaprogramming techniques between #alv and the modules, like basic polymorphism in this raymarching library:

    pic one is the user code, pic two is the library implementation.

    First the user declares the scene sample type they want to use by defining a shader module that contains a "Sample" type, an intial value, and a helper function that extracts the "distance" float from that type. This means they have complete autonomy over what material data they need (e.g. meterial identifiers, surface UVs, or whatever else).

    That shader module can be passed to an alive function that returns another shader module that implements common distance field operations (union, difference etc) on top of these primitives.

    Now the user can define a second shader module that contains the scene function (using the SDF utils), and give that back to the library which uses it to provide "castRay" and "calcNormal", which the primary user module can include to render the scene.

    Unlike GLSL #define-type approaches, you could even instantiate multiple scenes with different result types if you wanted to

    #theWorkshop

  41. What's pretty neat is that I have wesl-lang.dev with its module system now! That means I can trivially consume lygia.xyz now :)

    I'm also finding some interesting metaprogramming techniques between #alv and the modules, like basic polymorphism in this raymarching library:

    pic one is the user code, pic two is the library implementation.

    First the user declares the scene sample type they want to use by defining a shader module that contains a "Sample" type, an intial value, and a helper function that extracts the "distance" float from that type. This means they have complete autonomy over what material data they need (e.g. meterial identifiers, surface UVs, or whatever else).

    That shader module can be passed to an alive function that returns another shader module that implements common distance field operations (union, difference etc) on top of these primitives.

    Now the user can define a second shader module that contains the scene function (using the SDF utils), and give that back to the library which uses it to provide "castRay" and "calcNormal", which the primary user module can include to render the scene.

    Unlike GLSL #define-type approaches, you could even instantiate multiple scenes with different result types if you wanted to

    #theWorkshop