Can we resize size_t in C?

Can I resize size_tin C?

+2
source share
3 answers

size_tnot a macro. This is typedeffor a suitable unsigned integer type.

size_tdefined in <stddef.h>(and other headers).

This is probably typedef unsigned long long size_t;, and you really shouldn't even think about change. The standard library uses it as defined in the standard library. If you change it because you cannot change the standard library, you will get all kinds of errors, because your program uses a different size for size_t than the Standard library. You can no longer call malloc(), strncpy(), snprintf(), ...

+4
source

No. But why do you have to do this?

+8
source

fork Linux NetBSD, ""

, , , typedef.

, size_t . C99, size_t.

, . , .

But if you define a source environment with one or more compilers, then the answer is yes , but you have work cut out for you. You will need to implement all library procedures with an API element size_tthat can be compiled with the rest of your code using the new size_ttypedef. So, if you fork NetBSD or Linux, perhaps for an embedded system, then go for it. Otherwise, you may find it "not worth the effort."

+1
source

Source: https://habr.com/ru/post/1722264/


All Articles