October 22, 2024
Chicago 12, Melborne City, USA

C++

C++ is a general-purpose programming language. Use this tag for questions about/utilizing C++. Do not also tag questions with [c] unless

C++

What are your effective methods to find relevant docs for C, not C++?

To get a few obvious things out of the way: I am aware that C++ and C do not have official docs due to how the standard ISO specifications are written, etc. However, I am wondering how gcc/C developers (specifically non-C++ devs) find docs for their C specification/compiler, without pollution of information relating to C++

Read More
C++

Macro that expands to value or empty, based on boolean argument

I’m generating some compile-time code. I need to append a suffix to a generated function name, based on a macro boolean. The suffix is either present or empty. How to do that? #define FUNC_NAME(name, hasSuffix) name ## MAYBE_SHOW_SUFFIX(hasSuffix) FUNC_NAME(foo, true); // would generate: foo_ FUNC_NAME(foo, false); // would generate: foo You need to sign in

Read More
C++

Since when have the notifications registered by LdrRegisterDllNotification() started to work differently?

The Microsoft’s documentation about the function LdrRegisterDllNotification() states that DLL load notifications registered by this function: Registers for notification when a DLL is first loaded. This notification occurs before dynamic linking takes place. I wrote the following test program to test this assertion and while these notifications act according to the documentation in Windows 7

Read More
C++

Why can I see the shell variable with argv?

So, I was testing something with argc and argv in C language, and i discovered this. #include <stdio.h> int main(int argc, char *argv[]) { printf(%s\n", argv[2]); } I compile it and rum this from my terminal like this ./a.out, and the result is SHELL=/bin/bash, my shell variable… I use foot, the default terminal of sway.

Read More
C++

How can I stop a blank/tab from being outputted if there is a blank/tab before?

I’m using K&R’s “The C Programming Language” and was currently doing Exercise 1-12. The problem is not in resolving the exercise, but in trying to resolve one of the bugs that arise from it. My solution. #include <stdio.h> int main(void) { int c; while ((c = getchar()) != EOF) { if (c == ' '

Read More
C++

Cortex-M loading 32-bit variable optimization

I’m trying to compile the following test code below, that only writes the 32-bits variable into a pointer. I write it once as byte access, and second time as word access. void load_data_8(uint32_t value, void* d) { uint8_t* d_ptr = d; *d_ptr++ = (value>>0)&0xFF; *d_ptr++ = (value>>8)&0xFF; *d_ptr++ = (value>>16)&0xFF; *d_ptr++ = (value>>24)&0xFF; *d_ptr++ =

Read More
C++

Sending Data from MAX78000FTHR Microcontroller to NodeMCU via UART Protocol

I’m currently working on a project where I need to send data from a MAX78000FTHR microcontroller to a NodeMCU (ESP8266) using the UART protocol. I’ve set up both devices and would like to establish a reliable communication channel between them. Connections: MAX78000FTHR TX (Transmitter) → NodeMCU RX (Receiver) MAX78000FTHR RX (Receiver) → NodeMCU TX (Transmitter)

Read More
C++

How should I handle errors in Wayland event handler callbacks in C?

I’m just getting started with Wayland and I think I understand the basics, but I’m wondering how to handle errors that occur within event handler callbacks. Is there a standard way of doing this? I presume higher-level languages would use exceptions or something, but since we don’t have that luxury in C, what do people

Read More
C++

AppImage 'symbol lookup error' in libc library

I created a AppImage file on a system but cant run on other system. I get the following error: $LD_LIBRARY_PATH=$APPDIR/usr/lib/libc.so.6 ./Programik-x86_64.AppImage /tmp/.mount_PrograVkCV6J/usr/bin/p: symbol lookup error: /tmp/.mount_PrograVkCV6J/usr/bin/../lib/libc.so.6: undefined symbol: _dl_audit_symbind_alt, version GLIBC_PRIVATE sometimes I get: /tmp/.mount_PrograYCt79i/usr/bin/p: symbol lookup error: /tmp/.mount_PrograYCt79i/usr/bin/../lib/libpthread.so.0: undefined symbol: _dl_make_stack_executable, version GLIBC_PRIVATE LD_DEBUG=libs ./my-prog.AppImage output is same, refer here https://pastebin.com/9ACH9Y41 When I create

Read More
C++

C debugger Not able to Print or take Input when in debugger mode

I am not able to input anything on terminal in debugger. I have installed C/C++ set up, codeLLB and code runner extensions, as well. My lanch.json: { // Use IntelliSense to learn about possible attributes. // Hover to view descriptions of existing attributes. // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ { "name":

Read More