Products > Programming

Are data type compiler-dependent or target dependent

(1/16) > >>

King123:
I am being confused with data type in c programming language.

My question:

Are data type compiler-dependent or target dependent?

golden_labels:
What exactly do you mean by “data type”? Or ather, what kind of dependence do you mean?

If you mean ranges, sizes, representation: both the compiler and the platform. Even more: may also depend on particular options passed to the compiler. The platform limits what makes sense, so it’s the primary factor, but not the only one.

tellurium:

--- Quote from: King123 on August 02, 2022, 01:19:22 pm ---I am being confused with data type in c programming language.

My question:

Are data type compiler-dependent or target dependent?

--- End quote ---

There are basic types, like int, long. They do not require any header file. Their size depends on the target. For example, if you're compiling on 64-bit Windows machine using Arduino IDE, the AVR compiler uses 8-bit AVR compiler as a target, where "int" type is 2 bytes. If you're compiling for the 64-bit Windows, the "int" type would be 4 bytes.

There are other types, like size_t, uitn32_t, etc. They do require header files. When C compiler compiles a piece of code, all headers gets inlined and more complex types resolve to the basic types. The header files are, too, depend on the target. Usually, header flies are bundled together with the compiler.

Hope that clarifies

DiTBho:

--- Quote from: King123 on August 02, 2022, 01:19:22 pm ---Are data type compiler-dependent or target dependent?

--- End quote ---

data-type is always the same, but the data-size is a bit weird

e.g.
on MIPS4 "long" means 64-bit, "long long" means 64-bit
on hc11, gcc 3.0.*, "int" means 16 bit, while with icc-v11, "int" means 32-bit
on hc11, gcc.3.4.6 + patch, "int" are either 16 or 32-bit entities depending on a special flag

DiTBho:
endianess { BE, LE } is also target dependent.
MIPS, SH, POWER and PowerPC can be LE or BE depending on a configuration bit at boot.
AMD and intel x86 are always LE.

Navigation

[0] Message Index

[#] Next page

There was an error while thanking
Thanking...
Go to full version