Linked Questions

0 votes
1 answer
265 views

how to make a static struct from typedef [duplicate]

I have a header file list.h and a source file list.c,which define the functions in list.h. I have a struct here: typedef struct ListNode{ struct ListNode* next; struct ListNode* prev; void *...
Van Teo Le's user avatar
361 votes
11 answers
147k views

What does a type followed by _t (underscore-t) represent?

This seems like a simple question, but I can't find it with the Stack Overflow search or Google. What does a type followed by a _t mean? Such as int_t anInt; I see it a lot in C code meant to deal ...
Kevin Griffin's user avatar
190 votes
24 answers
161k views

Error handling in C code

What do you consider "best practice" when it comes to error handling errors in a consistent way in a C library. There are two ways I've been thinking of: Always return error code. A typical function ...
Laserallan's user avatar
  • 11.3k
96 votes
15 answers
51k views

Is it a good idea to typedef pointers?

I looked through some code and noticed that the convention was to turn pointer types like SomeStruct* into typedef SomeStruct* pSomeStruct; Is there any merit to this?
Unknown's user avatar
  • 46.7k
113 votes
16 answers
41k views

Valid use of goto for error management in C?

This question is actually a result of an interesting discussion at programming.reddit.com a while ago. It basically boils down to the following code: int foo(int bar) { int return_value = 0; ...
Eli Bendersky's user avatar
82 votes
13 answers
58k views

How can I simulate OO-style polymorphism in C?

Is there a way to write OO-like code in the C programming language? See also: Can you write object-oriented code in C? Object-orientation in C Found by searching on "[c] oo".
prinzdezibel's user avatar
  • 11.1k
39 votes
16 answers
24k views

Run C or C++ file as a script

So this is probably a long shot, but is there any way to run a C or C++ file as a script? I tried: #!/usr/bin/gcc main.c -o main; ./main int main(){ return 0; } But it says: ./main.c:1:2: error: ...
Brendan Long's user avatar
  • 54.2k
106 votes
3 answers
57k views

What is an opaque pointer in C?

May I know the usage and logic behind the opaque pointer concept in C?
Renjith G's user avatar
  • 4,848
42 votes
5 answers
24k views

What is an opaque value in C++?

What is an "opaque value" in C++?
Tony The Lion's user avatar
8 votes
3 answers
2k views

Does the ISO 9899 standard has reserved any use of the _t suffix for identifiers?

I can read in many books and an other SO questions that the standard may expand the set of identifiers such as size_t or int32_t, so it reserves any use of the _t suffix for identifiers. Is that ...
nowox's user avatar
  • 28.9k
4 votes
8 answers
576 views

Typedefing pointer types

I've been reading around SO and have come across the following questions which touch on why typedefing pointer types is bad. Opaque C structs: how should they be declared? and Const-correctness and ...
jay.lee's user avatar
  • 19.8k
5 votes
3 answers
1k views

Providing helper functions when rolling out own structures

if I am developing a C shared library and I have my own structs. To make common operations on these struct instances easier for library consumers, can I provide function pointers to such functions ...
upInCloud's user avatar
  • 999
3 votes
2 answers
3k views

Best way to read from a sensor that doesn't have interrupt pin and requires some time before the measurement is ready

I'm trying to interface a pressure sensor (MS5803-14BA) with my board (NUCLEO-STM32L073RZ). According to the datasheet (page 3), the pressure sensor requires some milliseconds before the measurement ...
Alexis Nicole's user avatar
7 votes
3 answers
557 views

Const-correctness and immutable allocated objects

During a recent discussion (see comments to this answer), R.. recommended to never create aliases for pointer-to-const types as you won't be able to deallocate the referenced objects easily in a ...
Christoph's user avatar
  • 169k
2 votes
2 answers
3k views

Header Files not including correctly

I have the following two header files: player.h #ifndef _PLAYER_H_ #define _PLAYER_H_ #include "map.h" typedef struct{ char* name; int x; int y; int keyMapping; char symbol; }...
Steampunkery's user avatar
  • 3,874

15 30 50 per page