408,321 questions
5
votes
2
answers
66
views
Is it portable to cast an unsigned value to its signed version to prevent underflow?
Suppose we have the following C code:
unsigned int a = 64;
int b = a - 128;
This arithmetic will cause an underflow, because the calculation is unsigned. Hence, the result will be a very large number....
1
vote
0
answers
123
views
C implicit const casting (in dereferencing order) should be permitted but isn't
For context, I have a function to print some text, which naturally takes in a const char *const * as one of its arguments (meaning the provided text will not be modified in any way by the function). ...
-1
votes
0
answers
44
views
ESP32-S3 (Espressif IDE / esp-gdb) stepping enters code with "no source available"; GDB skip rules do not work
I am debugging an ESP32-S3 project using Espressif IDE (Eclipse) + ESP-IDF. I can attach, halt, set breakpoints, and disassemble, but stepping is painful because the debugger always enters functions ...
Tooling
0
votes
9
replies
112
views
Is there any way to swap special characters to common ones with no punctuation in C?
I am dealing with a spanish .txt dictionary.
As you may (or may not know), some words contain special punctuation that defines explicit accent in certain vowels: á, é, í, ó, ú.
I want to create a .C ...
3
votes
2
answers
86
views
GDB typecasting failure in C
I was setting up gdb on vscode on windows and it wasn't working. I soon found out that it was erroring giving me a SIGSEGV segfault.
I tried gdb in powershell with the same problem.
I run the program ...
-2
votes
1
answer
132
views
How can I parse ASCII byte input into integers for dates and readings in C? [closed]
I have a C function that receives data from an input source (e.g., a USB stick or sensor), where the input is ASCII characters representing numeric values. For example, I might receive:
"12/04/23&...
1
vote
1
answer
82
views
WS2812 LED flickers when changing potentiometer value (ADC interrupt + Raspberry Pi Pico)
Context:
I am working on a Raspberry Pi Pico project where a potentiometer controls the volume (0–100%), and the volume is visualized on a WS2812 LED strip as a smooth color gradient from green (0) to ...
0
votes
0
answers
75
views
What do modern libraries like numpy or scipy specifically do in order to achieve partial pivoting during matrix inversion?
As an exercise problem I am trying to write a program that will invert matrices using the method of LU decomposition with partial pivoting. I sort of understand LU decomposition but was struggling to ...
0
votes
0
answers
44
views
code composer studio msp430g2231. variable in for loop stays at the initial value after flashing
I expect the variable i to decrement and make the led on P1.0 to go from slow blinking to fast blinking, then repeat. I turned off optimizations in code composer studio but the led blinks at a ...
0
votes
0
answers
48
views
C LSP losing context [closed]
I'm working in a large C Zephyr RTOS workspace in VS Code, and the LSP gives errors on the lines of:
identifier "ENUM_VARIANT" is undefined
and
incomplete type "const struct ...
3
votes
3
answers
128
views
Nested preprocessor macro compilation problem
I am compiling the CURL library, and in doh.c I am facing a compilation error:
#define STRCONST(x) x,sizeof(x)-1
#define Curl_dyn_addn(a,b,c) curlx_dyn_addn(a,b,c)
Curl_dyn_addn(c, STRCONST(".&...
1
vote
2
answers
138
views
fgets doesn't return NULL when it reaches to the EOF
I was trying to make a program that erases spaces and comments from a text file:
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#define SIZE 10
static inline bool ...
-3
votes
1
answer
69
views
Can USB CDC receive data byte-by-byte in CDC_Receive_FS(), or is it always packet-based?
I’m working with an STM32 microcontroller using USB CDC (Virtual COM Port) and handling incoming data in CDC_Receive_FS(). I want to understand the behavior for UART-style communication:
If the host ...
4
votes
2
answers
164
views
Are anonymous structures/unions compatible with their "flattened" form in C17?
Consider the following struct types, declared in different translation units:
// Defined in translation unit 1
struct s { int x; };
// Defined in translation unit 2
struct s { struct { int x; }; };
...
1
vote
0
answers
68
views
cannot find -lc_nano while compiling gba bootstrap
I am trying to build a simple gba-bootstrap project - the default one - just to confirm that everything is installed and setup correctly, and got an error:
/opt/devkitpro/devkitARM/bin/../lib/gcc/arm-...