407,792 questions
2
votes
3
answers
56
views
How does the block scope work?How does the standard explain this?
For example, we have such code:
#include <stdio.h>
int main(void)
{
int n = 4;
{
n++;
}
printf("%d\n",n);
return 0;
}
How does the inner block see the ...
2
votes
1
answer
91
views
Annotating intentional infinite loop to satisfy "-fanalyzer"
I have a following embedded system optimization case (simplified).
int main() {
while (1) {
// Do something
if (unrecoverable_error) {
__breakpoint();
while(1);
}
}
}
...
-1
votes
0
answers
39
views
Why won’t my image blur in my C blur filter implementation?
I'm working on a blur function in C:
void blur(int height, int width, RGBTRIPLE image[height][width])
{
RGBTRIPLE copy[height][width];
double pixels = 0;
double sumRed = 0;
double ...
1
vote
1
answer
43
views
When the bitfield is written in the for loop, the behavior of -fstrict-volatile-bitfields is incorrect and the strb instruction is generated
Compiler:
arm-gnu-toolchain-13.2.rel1-mingw-w64-i686-arm-none-eabi
I use bitfields to write peripheral registers, and can only write 32-bit, so cannot use strb. I used the gcc -fstrict-volatile-...
1
vote
0
answers
16
views
Replay a FreeRDP Session
I have setup FreeRDP on Windows using vcpkg, CMAKE, Visual Studio Build Tools, Windows SDK and have got the exe and dll files after building the repo.
I am connecting to a RDP machine using sdl2-...
1
vote
0
answers
21
views
communication i2c SHTP inertial sensor IMU bno080 sparkfun
I'm a student and I can't communicate with my inertial sensor.
I've been stuck on this code for weeks. I have to code it in low-level C because the Arduino IDE is apparently too simple for teachers.
I'...
2
votes
1
answer
48
views
How to document types like "unsigned short accum"
Is there a way in Doxygen to document types like unsigned short accum or long long sat fract? It's supposed to be in a documentation of stdfix.h (ISO/IEC TR18037), and the documentation should ...
1
vote
1
answer
75
views
Subsampling an image in C [closed]
I am trying to subsample an image by taking every 2nd pixel, as follows:
void subsample(int height, int width, int colors, struct Image pixels_in, struct Image pixels_out) {
for (int i = 0; i < ...
1
vote
1
answer
37
views
Why __sync_or_and_fetch builtin in a loop renders as an endless loop with -O2 and -O3?
[SOLVED] Use __sync_fetch_and_or instead of __sync_or_and_fetch! The double amoor instruction maybe is still a bug.
[Disclaimer] This could be a bug in GCC but I am still new to RISC-V assembly to be ...
-7
votes
0
answers
61
views
Learn C With Open Source Linux [closed]
I recently installed a Linux-based open source system, and I want to learn the C programming language by studying its source code, as well as understand how basic tools and commands are implemented in ...
1
vote
1
answer
43
views
Is it valid to initialize a struct with const members allocated on the stack with alloca?
Considering that the type A is defined like this:
typedef struct a { const int a; } A;
I know that this code is valid:
A * foo = malloc(sizeof *foo); // Allocates uninitialized memory with no ...
4
votes
0
answers
96
views
How could I determine whether Clang supports a given SIMD instruction?
Is there a way I can determine whether the current version of the Clang compiler supports a given extended CPU instruction?
The way I knew how was this:
#if __has_builtin(__builtin_ia32_packssdw256)
[[...
-1
votes
1
answer
51
views
Avoid implicit conversion to double [closed]
Using a clang cross-compiler, with a buggy float abi.
Background:
Microcontroller does not support double precision arithmetics in the HW.
There is an option in the compiler to disable double ...
1
vote
1
answer
62
views
Why does calling two functions in a single statement not affect the value? [duplicate]
In this code:
// Stack using LinkedList //
#include <stdio.h>
#include <stdlib.h>
struct Node {
int data;
struct Node* next;
};
struct Node* top = NULL;
short isEmpty(void) {
...
0
votes
1
answer
32
views
X11: which event struct type is returned in a XI_TouchBegin event
I like to write a simple X11 application and need to know which event structure is returned if I got a XI_TouchBegin, XI_TouchUpdate and XI_TouchEnd.
If I got a XI_ButtonPress I can cast to ...