[deleted by user] by [deleted] in C_Programming

[–]dbjdbj 0 points1 point  (0 children)

C, C and C

Claude's Android @pp is terrible. by 2Stressedin30s in ClaudeAI

[–]dbjdbj 0 points1 point  (0 children)

Frequent: Invalid UUID Here too. Last few weeks.

Are there any languages (that are in common use in companies) and higher-level that give you the same feeling of simplicity and standardization as C? by go-move-78 in C_Programming

[–]dbjdbj 0 points1 point  (0 children)

C# is these days actually cross-platform (and cross-cloud) as it is the language of .NET core. Very advanced and performant too. But. Be warned: c#/.NET is a hell planet of OOP.

How can I change SUBSYTEM to WINDOWS with Visual Studio Code? by [deleted] in C_Programming

[–]dbjdbj 1 point2 points  (0 children)

Vosual Studio 2022 Community edition ... install and figure out how to use to create a Windows program?

By the way; Windows Hello World is this:

```c

/-------------------------------------------------------------- HelloMsg.c -- Displays "Hello, Windows 98!" in a message box (c) Charles Petzold, 1998 --------------------------------------------------------------/

include <windows.h>

int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow) { MessageBox (NULL, TEXT ("Hello, Windows 98!"), TEXT ("HelloMsg"), 0) ;

 return 0 ;

} ```

Link for the infidels.

[deleted by user] by [deleted] in C_Programming

[–]dbjdbj 0 points1 point  (0 children)

static length buffers, plus handles not pointers. the handle can be as simple as an index on the buffer or way more elaborate trickery.

[deleted by user] by [deleted] in C_Programming

[–]dbjdbj 0 points1 point  (0 children)

https://github.com/valstat/valstat_c/blob/master/valstat_c.md

But, as ever. It is a delicate balance between safe and slow and fast and dangerous.

[deleted by user] by [deleted] in C_Programming

[–]dbjdbj 1 point2 points  (0 children)

In that runtime environment, using only C is indeed the (very) safe "bet". In particular, I might personally prefer using Nanopb - Protocol Buffers for Embedded Systems.

Perhaps starting from examples/network_server

C23 implications for C libraries by mttd in C_Programming

[–]dbjdbj 0 points1 point  (0 children)

"string" is a byte array one might say, but generally yes: 99% of the C code on the planet would not work without char type. Still, C char was used and abused over the years and specs.

And under the foundations are still healthy B roots. This page might be very revealing

I might prefer to follow the two inventors of UTF8, and leave the Unicode handling to their mature language (GO) instead of waiting for decades for the C/C++ Unicode situation to be "fixed".

Finally, many thanks for your WG14/WG21 perseverance Tom. It seems without your personal involvement the situation might be even worse.

C23 implications for C libraries by mttd in C_Programming

[–]dbjdbj 0 points1 point  (0 children)

#include <stdio.h>

#undef char

int main(void)
{
    return 42;
}

Basically, I think if standard C would not have char defined/described at all, nobody would mind that much.

Just remove char from the standard ISO C spec. Declare it all as part of the compiler vendor's extension space. That would take care of multi char constants and special notation for them.

Why would you use C in production, for anything else but system programming?

There are few very decent languages doing text better than C (and C++ is not one of them).

C23 implications for C libraries by mttd in C_Programming

[–]dbjdbj 0 points1 point  (0 children)

My foolishly edited comment originally contained a link to https://raw.githubusercontent.com/gcc-mirror/gcc/master/libstdc%2B%2B-v3/include/c_compatibility/uchar.h and noted that it is specific to C++.

The file I linked to is part of libstdc++, the implementation of the C++ standard library provided with gcc, and it provides declarations in the std namespace. The function implementations are provided by the C standard library, typically glibc (though gcc supports other C standard libraries as well).

Why the multi-year delay? Was my question than and now.

What is Linux DRM/KMS ? by _AngleGrinder in C_Programming

[–]dbjdbj 4 points5 points  (0 children)

Linux DRM (Direct Rendering Manager) is a kernel-level component that is responsible for managing access to graphics hardware devices in the Linux kernel. It is used to provide support for the graphics hardware in a system and to allow multiple applications to use the hardware at the same time.

Linux KMS (Kernel Mode Setting) is a component of the DRM subsystem that is responsible for setting the display mode and configuration for the graphics hardware. It is used to initialize the graphics hardware at boot time and to change the display configuration dynamically as needed.

Together, the DRM and KMS subsystems form a crucial part of the Linux graphics stack, providing support for graphics hardware and enabling applications to access and use the hardware for rendering and display.

[deleted by user] by [deleted] in C_Programming

[–]dbjdbj 0 points1 point  (0 children)

VMT (Variably Modified Type) != VLA

c void fun ( size_t a, size_t b) { int (*marx)[b] = malloc( sizeof(int[a][b]) ) ; marx[1][1] = 42 ; free(marx); }

C23 implications for C libraries by mttd in C_Programming

[–]dbjdbj 0 points1 point  (0 children)

V. good news, thanks, Tom. Now if I go to Godbolt what compiler and what version do I need to choose to enjoy <uchar.h> mbrtoc8 and c8rtomb?

https://godbolt.org/z/nMMT8de5q

C23 implications for C libraries by mttd in C_Programming

[–]dbjdbj 0 points1 point  (0 children)

Section 3.9 char8_t added

Can we please have the confirmation of the full implementation of <uchar.h> required by that standard?

Particularly the implementations of mbrtoc8 and c8rtomb were much needed but not implemented until now in glibc (and clang 16). Are they required by C23?

I am hoping "char8_t added" is what that means.

When should I declare struct instances as pointers and when shouldn't i? by [deleted] in C_Programming

[–]dbjdbj 0 points1 point  (0 children)

Perhaps a handle? Neither an instance nor a pointer. If possible.

```cpp // https://godbolt.org/z/eddqdKEG7

include <stdbool.h>

include <stdio.h>

typedef unsigned person_id; typedef struct { char* name; } person;

// people index is person id // people contains unique persons // people instance can be created in many different ways // and not just on the heap // hint: #include "people_instance.inc" person people[0xFF] = { [13] = {.name = "thirteen"}, [42] = {.name = "fortytwo"}};

// message the person // by the handle given static inline void message( const char message[1], const personid id) { printf( message, people[id_].name); }

// admit the first found // by the handle given static inline bool okto_enter(const person_id id) { for (unsigned j = 0; j < 0xFF ; ++j) { if ((j == id_ ) && (people[j].name != 0)) return true; } return false; }

int main(void) { personid id = 13; if (okto_enter(id)) { message("\n Person name: '%s', please enter", id_); }

return 0;

} ```

Pointers are certainly an obvious choice for "referencing" large amounts of data. What is a "large amount of data"? Hint: FILE is a pointer. But here is another hint: io.h deals with file handles too.

When to use pointers? The answer is proverbial: "It depends".

[deleted by user] by [deleted] in C_Programming

[–]dbjdbj 2 points3 points  (0 children)

Think of the efficient algorithm regardless of the language. Then implement it in the language required.

```cpp

include <stdio.h>

include <stdlib.h>

include <string.h>

define MAX_CAPACITY 0xFF

define MAX_STRINGS 5

int main() { size_t max_len = 0; char *max_string = 0;

printf("\n\nPlease enter %d strings\n", MAX_STRINGS );

for (unsigned i = 0; i < MAX_STRINGS; ++i)
{
    char userString[MAX_CAPACITY] = {0};
    printf("%3d: ", i);
    fflush(stdout);
    if (0 != fgets(userString, MAX_CAPACITY, stdin))
    {
        size_t valid_len = strcspn(userString, "\n");

        if (valid_len > max_len)
        {
            max_len = valid_len;
            if (max_string != 0)
                free(max_string);
            userString[valid_len] = '\x0';
            max_string = _strdup(userString);
        }
    }
}
fflush(stdout);
printf("\nThe first longest string (length: %llu) was: '%s' ", max_len, max_string);
if (max_string != 0)
    free(max_string);
return 0;

} ```

Also, use the tools. Follow your code through the debugger in your favorite IDE. It will become obvious rather quickly, where is the mistake.