General Programming Discussion

7758 readers
9 users here now

A general programming discussion community.

Rules:

  1. Be civil.
  2. Please start discussions that spark conversation

Other communities

Systems

Functional Programming

Also related

founded 5 years ago
MODERATORS
1
 
 

This new edition has been the occasion to overhaul the presentation in many places, but its main purpose is the update to the new C standard, C23. The goal was to publish this new edition of Modern C at the same time as the new C standard goes through the procedure of ISO publication. The closest approximation of the contents of the new standard in a publicly available document can be found here. New releases of major compilers already implement most of the new features that it brings.

2
 
 

So far, I've followed a simple Tor interceptor tutorial on YouTube, while strictly adhering to C2x with every warning flags enabled - not that it is the optimal way to go about learning the language.

I may have, or may not have inadvertently used improper C2x, but I've used typedef aggressively to slightly mimic Golang.

Almost a year ago, I had blindly translated a C++ Vulkan tutorial to C, and I didn't understand a single thing about anything graphics-related - framebuffer, swapchain, etc.

Now that I am learning it again from scratch, I also wanted to know what to learn next, as well as some of the job opportunities that I can explore.

3
 
 

RINA offers a lot of

4
5
 
 

This is a simple experimental Lisp compiler, written in uLisp, that will compile a Lisp function into RISC-V machine code. You can run the compiler on the RISC-V core of a Raspberry Pi Pico 2 (or another RP2350-based board)

6
7
 
 

We are thrilled to announce the release of Qt 6.8, packed with support for new desktop, mobile, and embedded platforms, hundreds of improvements, and exciting new features to boost your development experience and meet the needs of demanding applications.

For this release we have focused on improving and stabilizing existing functionality. With over 500 bug fixes and performance improvements since Qt 6.7, your existing code will run better without changing a single line. On macOS, Qt Quick applications now integrate with the native menu bar, and for a native Windows 11 look they can use the new Fluent style. Resizing Quick windows is snappier on macOS with Qt 6.8, and on Windows the application start-up time has been improved by changing the default font database to DirectWrite.

Several modules that were under technology preview have been completed: Qt Graphs, Qt HttpServer, and Qt GRPC are promoted to be fully supported from this release on. Thanks to the feedback from our users we were able to finish those modules with substantial improvements since their initial introduction as technology previews.

8
 
 

cross-posted from: https://lemmy.ml/post/21033409

In the book authored by K.N.King, there's this example:

viewmemory.c

/* Allows the user to view regions of computer memory */

#include <stdio.h>
#include <ctype.h>

typedef unsigned char BYTE;

int main(void)
{
	unsigned int addr;
	int i, n;
	BYTE *ptr;
	
	printf("Address of main function: %x\n", (unsigned int) main);
	printf("Address of addr variable: %x\n", (unsigned int) &addr);
	printf("\nEnter a (hex) address: ");
	scanf("%x", &addr);
	printf("Enter number of bytes to view: ");
	scanf("%d", &n);
	
	printf("\n");
	printf(" Address               Bytes             Characters\n");
	printf(" ------- ------------------------------- ----------\n");
	
	ptr = (BYTE *) addr;
	for (; n > 0; n -= 10) {
		printf("%8X  ", (unsigned int) ptr);
		for (i = 0; i < 10 && i < n; i++)
			printf("%.2X ", *(ptr + i));
		for (; i < 10; i++)
			printf("   ");
		printf(" ");
		for (i = 0; i < 10 && i < n; i++) {
			BYTE ch = *(ptr + i);
			if (!isprint(ch))
				ch = '.';
			printf("%c", ch);
		}
		printf("\n");
		ptr += 10;
	}
	
	return 0;
}

For some reason, when I try to enter addr variable address as the parameter, it has a segmentation fault error. However, in the book's example and the screenshot from this site in Hangul, there's no such error?

When I try using gdb to check the issue, here's what I get:

gdb

$ gdb ./a.out  --silent
Reading symbols from ./a.out...
(gdb) run
Starting program: /home/<username>/Desktop/c-programming-a-modern-approach/low-level-programming/a.out 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/gnu/store/zvlp3n8iwa1svxmwv4q22pv1pb1c9pjq-glibc-2.39/lib/libthread_db.so.1".
Address of main function: 401166
Address of addr variable: ffffd678

Enter a (hex) address: ffffd678
Enter number of bytes to view: 64

 Address               Bytes             Characters
 ------- ------------------------------- ----------

Program received signal SIGSEGV, Segmentation fault.
0x000000000040123a in main () at viewmemory.c:31
warning: Source file is more recent than executable.
31	        printf ("%.2X ", *(ptr + i));
(gdb)

What is going on? By the way, I am using Guix, if that matters in any way. Here's the output for ldd:

ldd

$ ldd ./a.out 
	linux-vdso.so.1 (0x00007ffecdda9000)
	libgcc_s.so.1 => /gnu/store/w0i4fd8ivrpwz91a0wjwz5l0b2ralj16-gcc-11.4.0-lib/lib/libgcc_s.so.1 (0x00007fcd2627a000)
	libc.so.6 => /gnu/store/zvlp3n8iwa1svxmwv4q22pv1pb1c9pjq-glibc-2.39/lib/libc.so.6 (0x00007fcd2609c000)

9
 
 

Recently I wondered what I get in term of C++ features for upgrading my system from version 13 to 14 of GCC...

Now, of course - a lot of bug fixes. Its surely a good idea to upgrade. But that doesn't answer my question. So a quick look at C++ compiler support showed that there is some interesting features, and mostly first C++26 support becoming available is one of them. Other features are more important to me though.

10
11
12
13
 
 

In my journey to learning C, I've come across header files, which are used to (I'm assuming) define a prototype for the source file, as well as structure modules. This feature, in my opinion, is pointlessly not just redundant, but possibly a source for pitfall. The same information can probably be extracted from the source code, if not for the restrictions of the language specification in C.

Say, if I have a GTK project, I will have to use the preprocessor directive, that will require the use of GTK headers that look something like #include <gtk/gtk.h>, and they're usually in the system path. How do modern languages, like Rust, Zig or Go deal with this situation, where shared libraries are used?

14
 
 

Vulkan 1.3.296 is out as the first spec update in nearly one month. Given the time that has passed there are more bug fixes than usual but there is also a prominent new extension: VK_EXT_device_generated_commands. It has been worked on by Valve's Linux graphics driver developers along with engineers from Intel, AMD, NVIDIA, Collabora, and others. This new extension allows for the GPU device to generate a number of commands for command buffers.

15
 
 

Is there a way to scale the Lightness in OKLab/OKLCH color space, so it becomes identical to lightness in CIELAB? I want use OKLab to create tonal palettes, that requires a change in lightness scale since OKLab's lightness scale perfoms poorly in this regard.

16
 
 

cross-posted from: https://lemmy.pierre-couy.fr/post/678825

Hi ! I've been working on this article for the past few days. It would mean a lot to me if you could provide some feedback.

It is about implementing a physico-chemical simulation as my first attempt to write a shader. The code is surprisingly simple and short (less than 100 lines). The "Prerequisite" and "Update rules" sections, however, may need some adjustments to make them clearer.

Thanks for reading

17
 
 

Two-dimensional vector graphics has been quite prevalent in recent Qt release notes, and it is something we have plans to continue exploring in the releases to come. This blog takes a look at some of the options you have, as a Qt developer.

In Qt 6.6 we added support for a new renderer in Qt Quick Shapes, making it possible to render smooth, anti-aliased curves without enabling multisampling. The renderer was generalized to also support text rendering in Qt 6.7, and, in the same release, Qt SVG was expanded to support a bunch of new features.

And there is no end in sight yet: In Qt 6.8 we are bringing even more vector graphics goodies to the Qt APIs. In this blog, I will share some details on the different ways vector graphics can be used in Qt, as well as the benefits and drawbacks of each.

18
19
20
7
submitted 1 month ago* (last edited 1 month ago) by Ghoelian@lemmy.dbzer0.com to c/programming@lemmy.ml
 
 

I'm really bad at keeping my dependencies up-to-date manually, so dependabot was great for me. I don't use github anymore though, and I haven't really been able to find a good alternative.

I found Snyk, which seems to do that, but they only allow logging in with 3rd party providers which I'm not a big fan of.

Edit: seems like Snyk also only supports a few git hosts, and Codeberg isn't one of them.

21
22
23
24
25
 
 

Taking accurate screenshots with Puppeteer has been a real pain, especially with pages that don’t fully load when the standard waitUntil: load fires. A real pain. Some sites, particularly SPAs built with Angular, React, or Vue, end up half-loaded, leaving me with screenshots where parts of the page are just blank. Peachy, just peachy.

I've had the same issue with waitUntil: domcontentloaded, but that one was kind of expected. The problem is that the page load event fires too early, and for pages relying on JavaScript to load images or other resources, this means the screenshot captures a half-baked page. Useless, obviously.

After some digging accompanied by a certain type of language (the beep type), I did find a few workarounds. For example, you can use Puppeteer to wait for specific DOM elements to appear or disappear. Another approach is to wait for the network to be idle for a certain time. But what really helped was finding a custom function that waits for the DOM updates to settle (source). It’s the closest to a solution for getting fully loaded screenshots across different types of websites, at least from what I was able to find. Hope it will help anyone who struggles with this issue.

view more: next ›