c Questions

2

Solved

Assuming alignment is a uintptr_t power of 2, looking for the next properly aligned address can be done using this expression: (address + alignment - 1u) & ~(alignment - 1u) This is used in cu...
Earthwork asked 23/10 at 23:36

2

Solved

I have a datafile. #version 460 core out vec4 FragColor; void main() { FragColor = vec4(1.0f, 0.5f, 0.2f, 1.0f); } And I am trying to read the contents of it with fread. FILE *fshader; char *f...
Myeloid asked 25/10 at 1:40

1

Solved

If we look at a few modern calling conventions, like x86-64 SysV style or AArch64 style (document aapcs64.pdf titled "Procedure Call Standard for the Arm® 64-bit Architecture"), we see ex...
Stentorian asked 23/10 at 10:57

5

I'm hoping this isn't a duplicate question, but I've searched in some detail and haven't found my exact case before. I have a simple struct that I also want to be able to access as a simple byte a...
Inhabitancy asked 7/5, 2014 at 18:46

2

Solved

I want to find the index of the first integer in an array of integers which is <= key. I can do it with binary search in log2(N)+1 compares. Shouldn't it be possible with only log2(N) compares? ...
Dg asked 13/8, 2015 at 18:48

0

I am trying to load a firmware file to a specific physical address in RAM on an arm64 device. The device tree already has an entry that defines the region of memory and uses no-map to prevent Linux...

4

Solved

I want to parallelize this code getting the best performance. "histogram" stores number of appareances of a certain colour (there are 10 different colours, so the size of histogram is 10). "img" is...
Chenopod asked 14/2, 2014 at 11:12

4

Solved

Header file math.h is for mathematical functions like cos,sin, tan.. But how to write the ln function and not log?
c
Wein asked 10/12, 2015 at 15:3

3

Is there any way to get back the characters outputted into a variable on ncurses ? let's say I do: printw("test"); then I want to be able to: somefunc(strbuffer); printf("%s",strbuffer); // te...
Churr asked 17/6, 2010 at 19:51

1

I am trying to compile a simple hello program using gcc, but getting the below error. i am using ubuntu. gcc -g -o hello hello.c collect2: fatal error: ld terminated with signal 11 [Segmentatio...
Odeen asked 16/7, 2019 at 21:9

2

Solved

So compiling C on VS Code on Windows is an absolute nightmare. The only way I am able to "force" VSCode to compile and debug my C/C++ programs is by either: Starting VSCode through the D...
Myoglobin asked 8/9 at 3:36

7

Solved

I am little struggling how to make my output to show like this: a aa aaa My current output shows this instead: a aa aaa Below are my code: void displayA(int a){ for(int i = 0; i < a; i...
Exclave asked 2/9, 2014 at 15:17

4

I am currently working on program with a lot of source files. Sometimes it is difficult to keep track of what libraries I have already #included. Theoretically, I could make a single header file ca...
Incursive asked 5/12, 2014 at 4:27

3

The clock_gettime function requires a struct timespec object as an argument. https://linux.die.net/man/3/clock_gettime In the date and time utilities section of the C standard library, there is a f...
Terzas asked 16/8, 2021 at 14:22

2

I'm trying to read CP15 coprocessor in the following System-on-chip Cortex A7 - ARMv7-A Below my snippet void main (void) { unsigned int reg_value = 0; asm volatile("mrc p15, 0, %0, c0, c0, 0"...
Nedi asked 1/3, 2018 at 14:17

1

Solved

I recently tried to read assemblies of the binary of my code and found that a lot of floating-point operations are done using XMM registers and SSE instructions. For example, the following code: fl...
Deposit asked 11/9 at 11:52

9

Solved

I'm using C and sometimes I have to handle paths like C:\Whatever C:\Whatever\ C:\Whatever\Somefile Is there a way to check if a given path is a directory or a given path is a file?
Brisson asked 28/9, 2008 at 22:42

13

I am quite new to C and learning it partly also by going through Codility training. For the triplet question, however I am only getting 11 % I am not sure what is wrong here. The question is: A n...
c
Penitent asked 10/4, 2014 at 9:50

6

Solved

I have a char array that is really used as a byte array and not for storing text. In the array, there are two specific bytes that represent a numeric value that I need to store into an unsigned int...
Sarcocarp asked 25/10, 2011 at 17:12

3

Solved

Suppose I have a function which takes some pointer parameters - some non-const, through which it may write, and some const through which it only reads. Example: void f(int * a, int const *b); Supp...

3

Solved

C99 defines these three as macros that "are expressions of type ‘‘pointer to FILE’’ that point to the FILE objects associated, respectively, with the standard error, input, and output streams&...
Uncertainty asked 30/5, 2023 at 13:8

1

Solved

Considering local time. In testing some time code with the potential hundreds of time zones, some of them result in a mktime() call that never returns for select values! Detail: Code never returns ...
Cacie asked 2/9 at 1:48

1

Solved

The Vectorcall protocol is a new calling convention for Python's C API defined in PEP 590. The idea is to speed up calls in Python by avoiding the need to build intermediate tuples and dicts, and i...
Dna asked 25/8 at 20:35

1

Solved

Consider the following C program, named weird.c (because the thing it is doing makes no sense): #include <inttypes.h> #include <stdint.h> #include <stdio.h> #include <unistd.h&...
Patchy asked 30/8 at 4:38

8

Solved

In my program, I have a statement like the following, inside a loop. y = (x >= 1)? 0:1; However, I want to avoid using any relational operator, because I want to use SIMD instructions, and am...
Inez asked 29/4, 2017 at 9:0

© 2022 - 2024 — McMap. All rights reserved.