Welcome to Software Development on Codidact!
Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.
Activity for alx
Type | On... | Excerpt | Status | Date |
---|---|---|---|---|
Edit | Post #287748 |
Post edited: |
— | about 2 years ago |
Edit | Post #287748 |
Post edited: |
— | about 2 years ago |
Edit | Post #287748 |
Post edited: |
— | about 2 years ago |
Edit | Post #287748 |
Post edited: |
— | about 2 years ago |
Edit | Post #287748 |
Post edited: |
— | about 2 years ago |
Edit | Post #287748 |
Post edited: |
— | about 2 years ago |
Edit | Post #287748 |
Post edited: |
— | about 2 years ago |
Edit | Post #287748 | Initial revision | — | about 2 years ago |
Question | — |
Strict aliasing rules and function boundaries Let's analyze this code, assuming an architecture where the alignment of `int64t` is the same as that of `double`: ```c void bar(double f, int64t j) { (int64t )f = j; } void foo(void) { int64t i = 1; bar((double ) &i, &i); } ``` - The object is of type `int64t`. - ... (more) |
— | about 2 years ago |
Edit | Post #287522 |
Post edited: ffix |
— | over 2 years ago |
Edit | Post #287522 |
Post edited: reorder params |
— | over 2 years ago |
Edit | Post #285946 |
Post edited: |
— | over 2 years ago |
Edit | Post #287522 |
Post edited: revert last change. ***cat() functions have the common meaning of appending after finding a NUL; this one doesn't. |
— | over 2 years ago |
Edit | Post #287522 |
Post edited: Rename to stpecat() |
— | over 2 years ago |
Edit | Post #287522 |
Post edited: |
— | over 2 years ago |
Edit | Post #287522 |
Post edited: |
— | over 2 years ago |
Edit | Post #287522 |
Post edited: |
— | over 2 years ago |
Edit | Post #287522 |
Post edited: |
— | over 2 years ago |
Edit | Post #287522 |
Post edited: |
— | over 2 years ago |
Edit | Post #287522 | Initial revision | — | over 2 years ago |
Answer | — |
A: stpecpy(): Design a better string copy function that truncates After addressing @Lundin 's suggestions: - Implemented in terms of libc functions for performance. - const correctness - style improvements I have a few more that I realized after trying to replace some existing code: Much code out there has `char end = buf + nitems(buf);` (although that s... (more) |
— | over 2 years ago |
Edit | Post #287345 |
Post edited: parentheses |
— | over 2 years ago |
Edit | Post #287345 |
Post edited: |
— | over 2 years ago |
Edit | Post #287345 |
Post edited: |
— | over 2 years ago |
Edit | Post #287345 |
Post edited: decay arrays |
— | over 2 years ago |
Edit | Post #287345 |
Post edited: |
— | over 2 years ago |
Edit | Post #287345 | Initial revision | — | over 2 years ago |
Answer | — |
A: How to write a macro that discards the const qualifier, for any type? I developed this macro (using GNU C) similar to C++'s constcast(). ```c #define constcast(t, p) \ ({ \ staticassert(builtintypescompatiblep(typeof(&(p)), const t)); \ ... (more) |
— | over 2 years ago |
Comment | Post #286578 |
I was wondering about Unix systems in general, and Linux if there are differences across Unices. (more) |
— | almost 3 years ago |
Comment | Post #286628 |
...
The static assert would need to be at call site, but that would not make sure the function is not referenced anywhere else in the code. And a static assert at the A_* function definitions would always be triggered, as long as the functions are being compiled.
I only want to trigger it if t... (more) |
— | almost 3 years ago |
Comment | Post #286628 |
Okay, so the problem (the current code I'm dealing with) is:
A program might be compiled with support for feature A, or without support for it (I guess for having a slimmer/faster binary). The feature is basically some A_*() functions, and some calls to those functions from core functions.
Rig... (more) |
— | almost 3 years ago |
Edit | Post #286628 |
Post edited: tfix |
— | almost 3 years ago |
Edit | Post #286628 |
Post edited: renamed landmine() to assert_not_present_in_binary_if(), per Dirk's suggestion. |
— | almost 3 years ago |
Comment | Post #286628 |
That makes sense to me :) Thanks! (more) |
— | almost 3 years ago |
Edit | Post #286628 |
Post edited: |
— | almost 3 years ago |
Edit | Post #286628 |
Post edited: |
— | almost 3 years ago |
Edit | Post #286628 |
Post edited: |
— | almost 3 years ago |
Edit | Post #286628 |
Post edited: |
— | almost 3 years ago |
Edit | Post #286628 |
Post edited: |
— | almost 3 years ago |
Edit | Post #286628 |
Post edited: |
— | almost 3 years ago |
Edit | Post #286628 |
Post edited: |
— | almost 3 years ago |
Edit | Post #286628 | Initial revision | — | almost 3 years ago |
Answer | — |
A: Assert that some code is not present in the final binary, at compile or link time. Calling an undefined function will have that behavior at link time: `landmine.c`: ```c #ifndef CONSTANT #define CONSTANT 0 #endif #define assertnotinbinaryif(e) do \ { \ if (e) \ undefinedfunction(); \ } while (0) void undefinedfunction(void); [[gnu::noipa]] static void foo0(vo... (more) |
— | almost 3 years ago |
Edit | Post #286627 |
Post edited: |
— | almost 3 years ago |
Edit | Post #286627 |
Post edited: |
— | almost 3 years ago |
Edit | Post #286627 |
Post edited: |
— | almost 3 years ago |
Edit | Post #286627 |
Post edited: |
— | almost 3 years ago |
Edit | Post #286627 |
Post edited: |
— | almost 3 years ago |
Edit | Post #286627 |
Post edited: |
— | almost 3 years ago |
Edit | Post #286627 |
Post edited: |
— | almost 3 years ago |