Skip to main content
24 votes
4 answers
3k views

C23 added the classification macro iszero for testing whether an argument value is zero, specified like: int iszero(real-floating x); What is the difference between using iszero(x) and writing x == 0?...
Jan Schultke's user avatar
  • 44.5k
27 votes
2 answers
2k views

Consider this C (not C++!) code: int g(); int f() { return g(); } Clang (with any optimization level above zero) compiles this to: f: xor eax, eax jmp g@PLT I am trying ...
Brennan Vincent's user avatar
15 votes
3 answers
2k views

Take a look at the function SHA1Transform taken from an SHA1 algorithm on Github. Assuming SHA1HANDSOFF is defined, the function looks like this: void SHA1Transform( uint32_t state[5], const ...
Andreas's user avatar
  • 10.7k
12 votes
4 answers
1k views

Both amd64 and arm64 architecture processors have an overflow flag. However, in C, the most common method to detect whether an operation causes overflow/underflow is to make functions like these: int ...
Daniil Zuev's user avatar
10 votes
1 answer
674 views

Okay it probably doesn't. That would be weird. I'm guessing, I'm allocating my memory wrong somehow. #include <stdio.h> #include <stdlib.h> /*I have two Structs. In one there is a pointer ...
dedpunkrz's user avatar
  • 178
Advice
2 votes
11 replies
389 views

I watched a few tutorials on YouTube. They said to assume a 32-bit architecture and then said "a single CPU cycle can only access a word (equals the CPU's native size i.e 4 bytes) at a time from ...
Random Guy's user avatar
2 votes
5 answers
330 views

I have read about undefined behaviour for the C3 language here: https://c3-lang.org/language-rules/undefined-behaviour/ Here is the example from the page. Assume following code: uint x = foo(); uint z ...
rhall's user avatar
  • 118
0 votes
4 answers
442 views

I have a Shared Object (.so) file. Is there like any specific way i can check if it was generated from a c or c++ code file. Can we get any hints or specifics from the file to make an educated guess ? ...
Abhith Shaji's user avatar
Best practices
0 votes
15 replies
217 views

Working in C with a library which has a very complicated set of return codes. I have a function which takes a library's error code and converts it into my error code. If the resulting "my" ...
White Owl's user avatar
  • 1,556
Advice
1 vote
11 replies
215 views

I'm parsing a file, several fscanf attempts per line Do I have to check for EOF in the returns after each one or can I do a big for-loop and check EOF in the skip-to-next-line routine? cppreference ...
NooneAtAll3's user avatar
15 votes
3 answers
412 views

Often, I'd like to chain preprocessor conditionals involving __has_include (defined in C++17 and C23, and supported in earlier versions as an extension by many compilers (GCC 4.9.2 and up, and Clang ...
Noam Elul's user avatar
  • 854
7 votes
2 answers
303 views

C23 now has four different ways of computing the maximum or minimum of two floating-point numbers: x > y ? x : y for maximum (or the other way for minimum) fmax / fmin fmaximum / fminimum ...
Jan Schultke's user avatar
  • 44.5k
Advice
0 votes
8 replies
195 views

I have the following C code (an MWE): #include<time.h> void fun() { asm("arg1:"); struct timespec const a = { .tv_sec = 10, .tv_nsec = 0 }; asm("call_nanosleep:"); ...
user10732's user avatar
2 votes
3 answers
256 views

I'm trying to display the contents of some allocated memory byte by byte: #include <stdio.h> #include <stdlib.h> typedef struct { int len; int* vec[]; } vec_t; int main(void) { int ...
Mecki's user avatar
  • 99
-7 votes
3 answers
299 views

I’m learning pointer arithmetic in C and trying to access array elements using a pointer. Here is my code: #include <stdio.h> int main() { int a[3] = {10, 20, 30}; int *p = a; ...
Raghav Sharma's user avatar

15 30 50 per page
1
2 3 4 5
7