Behebung von C-Fehler 'unknown type name intptr_t'

English Deutsch

Problem:

Du hast C-Code wie

example.c
int v = 123;
intptr_t vptr = (intptr_t)&v;

aber wenn du versuchst, es zu kompilieren, siehst du eine Fehlermeldung wie

compile_error.txt
main.c: In function ‘main’:
main.c:5:1: error: unknown type name ‘intptr_t’; did you mean ‘__int128_t’?
 intptr_t vptr = (intptr_t)&v;
 ^~~~~~~~
 __int128_t
main.c:5:18: error: ‘intptr_t’ undeclared (first use in this function)
 intptr_t vptr = (intptr_t)&v;
                  ^~~~~~~~
main.c:5:18: note: each undeclared identifier is reported only once for each function it appears in

Lösung

Add

fix.c
#include <stdint.h>

am Anfang der Quelldatei, wo der Fehler aufgetreten ist.


Check out similar posts by category: C/C++, GCC Errors