39 questions from the last 7 days
0
votes
0
answers
23
views
I made a todo list matrix now how am I supposed to make it pointer based?
How do you initialize matrix value in c but in pointer?
void addTodo(char *todo)
{
int j = 0;
for (j; j < strlen(todo); j++)
{
matrix[CurrentTodoIndex1][j] = todo[j];// I wanna ...
Advice
0
votes
0
replies
19
views
Adding stack information to jit'd code for sanitization
Disclaimer: I'm expecting that the answer to this question will be that it can't be done, but I'm asking as a just in case.
I am working on a JIT'd language with the compiler and runtime implemented ...
Best practices
2
votes
1
replies
32
views
How to properly obtain info on current user session lock using PAM
I have a C application that uses pam to reauthenticate a user on a system with faillocks configured. Imagine something that would work similar to login on the outside.
However, it only does basic ...
2
votes
1
answer
75
views
Does creating multiple JWT authentication tokens mean multiple server sessions for concurrent requests?
I'm participating in an online Sudoku-solving challenge where you create an account, and the server gives you a JWT token. Every request (getting the board, submitting answers, etc.) must include that ...
Best practices
3
votes
6
replies
111
views
Avoiding array duplication in big integer routine
I am working on a multiplication routine in a big integer library in POSIX C99 with a signature of bigint_st *bigint_mul(bigint_st *dest, const bigint_st *a, const bigint_st *b). Many of the routines ...
2
votes
2
answers
151
views
I am trying to translate my C code into assembly but my code is not working. What is wrong with it?
I am trying to use an MSP-EXP3430G2ET with a Buzzer and a potentiometer on CCS. The goal of the program is to have 2 modes, a high frequency mode and a low frequency mode. If you press the button, it ...
1
vote
1
answer
49
views
„Why does my ICM-42688-P always read the same AX/AY/AZ values on PSoC (LED never changes)?“
I am using a PSoC 5LP together with the 6DOF IMU 14 Click (ICM-42688-P) from MikroE.
The IMU is connected via I²C, address 0x68, and the WHO_AM_I register correctly returns 0x47, so the sensor is ...
2
votes
1
answer
52
views
Window goes black when enabling GL_DEPTH_TEST?
I have a problem that my window:
// gcc -o minimum main.c -lglut -lGL
#include <stdio.h>
#include <unistd.h>
#include <GL/gl.h>
#include <GL/glut.h>
extern void ...
11
votes
7
answers
1k
views
Is it possible to expose C++ template struct (fully specialized) to C?
I want to use circular queue with different types and lengths in a project which mainly consists of C code. I'm thinking about implementing the circular queue as a C++ template struct. How to expose ...
Best practices
0
votes
6
replies
90
views
How to use file sets in CMakeLists
I'm currently writing CMakeLists for a multidirectory project,and am trying to use file sets and target_sources as it is regarded as better than using target_include_directories, but the only problem ...
0
votes
0
answers
77
views
Data Type Conversion in C for Readings from ADC [closed]
I am writing code for a microcontroller using the C programming language. The simplified operation of my program is to read a value from the Analog-to-Digital Converter (16-bit ADC, returning an ...
0
votes
0
answers
94
views
Does macOS have an equivalent of __FreeBSD_version? [closed]
This question about macro(s) that I would like to use for software development was closed because it does not concern programming or software development. For the benefit of reviewers that do not know ...
10
votes
1
answer
493
views
Is this a well-defined way to access bitfield bits by index in C11
The order of bits in C11 bitfields is implementation-defined, and so is any padding in between them. This makes it difficult to access the bitfields by index at runtime, even though most ...
2
votes
1
answer
125
views
Trying to learn how getchar works
I am encountering a problem inside a while loop that is embedded in a for loop iterating through a struct of arrays. The issues I am coming across is before the array iterates again, I want to have ...
1
vote
0
answers
68
views
How To Create Progress Into Thread In UEFI For Multitasking [closed]
UEFI By Default Starts OS With Single Core And Is Harder To Multitask In UEFI Using Start Progress In Thread. I am making OS Form Scratch For Multitasking But There Is No Option To Multitask In EDK 2 ...
Best practices
0
votes
14
replies
173
views
In C with stdarg, how can I pass a va_list to another function safely?
man stdarg shows, under the va_args macro description:
If ap is passed to a function that uses va_arg(ap,type), then the value of ap is undefined after the return of that function.
If we look at ...
Advice
0
votes
3
replies
111
views
Misunderstanding System V x86_64 ABI
My question is how this structure passed and returned from function?
struct S
{
int a[5];
};
I read ABI. As far as I understand if the size of structure less then 64 bytes it will separate to ...
8
votes
1
answer
174
views
If I start two strictly CPU bound threads bound to the same CPU, and one is SCHED_IDLE, why does it ever schedule?
If I start two threads bound to CPU 0, where one is SCHED_IDLE, then why is it ever scheduled when the other thread is CPU bound at either normal priority, or at SCHED_FIFO?
For SCHED_FIFO I get it, ...
3
votes
2
answers
112
views
Code is returning "[C Kernel] Executable exited with code -11", don't know what's wrong with it?
I'm working on this piece of code as part of my coursework, ideally any advice I get for this would be educational in some way; I don't want an exact answer, just need someone who knows more than I do ...
-1
votes
3
answers
211
views
Why does float f = 3.14; and float f = 3.14f; print the same value in C even though one is double and the other is float?
I am confused about the following behavior in C.
#include <stdio.h>
int main() {
float a = 3.14; // literal is double
float b = 3.14f; // literal is float
printf("%f\n"...