Skip to main content
13 votes
3 answers
951 views

Consider the following code: char *str = "1234"; long n = strtol(str, &str, 10); The prototype of strtol() in C99 is: long strtol(const char *restrict nptr, char **restrict endptr, int ...
Parminder Singh's user avatar
14 votes
3 answers
971 views

Consider the following code: void foo(size_t len, int array[static len]) { } int main(int argc, char *argv[]) { foo(0, NULL); return 0; } The function foo declares its second parameter using ...
Parminder Singh's user avatar
1 vote
1 answer
104 views

I'm writing a software in C99 which consists of two git repositories, one of them a submodule. The submodule declares an error code enum in a header: enum err_cause { ERR_CAUSE_A = 1, ...
juhist's user avatar
  • 4,546
4 votes
3 answers
251 views

I know that anonymous structs and anonymous unions are a GCC extension that was recently introduced to the C11 standard: struct named { int type; union { struct { int a; int b; ...
juhist's user avatar
  • 4,546
1 vote
0 answers
72 views

I am using SDL3 and I am running on a KDE Plasma DE. I have the following Event Loop: void platform_poll_events(platform_t* p, input_state_t* input) { SDL_Event evt; while(SDL_PollEvent(&...
user avatar
3 votes
2 answers
106 views

I'm doing a bit of retro-computing and try to build one of my pet projects on an SGI Indy running IRIX-6.5. $ uname -a IRIX IRIX 6.5 10070055 IP22 $ which gcc /usr/freeware/bin/gcc $ gcc -version ...
umläute's user avatar
  • 32.4k
8 votes
2 answers
292 views

If we have similar structs (Base, Derived1 and Derived2) that both have a first element of type int: typedef struct stBase { int type; } Base; typedef struct stDerived1 { int type; // same ...
Sonic78's user avatar
  • 898
5 votes
1 answer
249 views

I'm working on a C99 project that is required to follow the MISRA C:2012 standard. Whenever I use an enumeration type, I get a violation of rule 10.4 or 10.5. As a static analysis tool, I use the code ...
Jelly00's user avatar
  • 53
Best practices
3 votes
6 replies
154 views

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 ...
Eric Pruitt's user avatar
  • 1,903
14 votes
4 answers
1k views

C89 and C99 do not provide an alignof macro as part of the standard library (nor an alignof keyword as part of the language as done by C23). C programmers found out they can define their own version ...
Random Citizen's user avatar
4 votes
1 answer
249 views

In C89 and C99: Is sizeof on anonymous structs standard conformant? sizeof(struct{long l; void* ptr;})
Random Citizen's user avatar
0 votes
1 answer
109 views

In the SDL_Surface structure, is there a way to calculate the bounds of the pixels Member? I need a quicker way of doing this, so my code doesn't catch seg-faults while running. On my Linux Laptop, ...
SpedTech XR's user avatar
0 votes
1 answer
291 views

(major edit of the question) I'm using arm-none-eabi-gcc 10.2. The following code const double d = 1.0; int main() { return d*d; } compiled with arm-none-eabi-gcc -Wall -Wextra -Wpedantic -...
Guillaume Petitjean's user avatar
3 votes
3 answers
258 views

char my_array[10]; Let's say threadA changes the value of my_array[0] and threadB changes the value of my_array[1], is this thread safe? A similar question has already been asked Is access to ...
Parminder Singh's user avatar
5 votes
3 answers
187 views

size_t array_len = SIZE_MAX; int *my_array = calloc(array_len, sizeof(int)); int compar(const void *n_to_search, const void *arr_element) { if(*(int *)n_to_search > *(int *)arr_element) ...
Parminder Singh's user avatar

15 30 50 per page
1
2 3 4 5
132