Portál AbcLinuxu, 7. května 2025 14:55
...než dělat trolla v disuzích...K teme:
Typo:Dík, opraveno.
Jestli to s těmi const Linus myslí vážně, tak mám pocit, že zešílel. Protože const slouží k označení konstatní věci.Pokud vím, tak specifikace jazyka C tvrdí něco jiného.
short s; void *v; s = (int)v & 0xffff;
Any pointer type may be converted to an integer type. Except as previously specified, the result is implementation-defined. If the result cannot be represented in the integer type, the behavior is undefined. The result need not be in the range of values of any integer type.
Mě se ten kód zkompiluje,No, gcc to vezme, ale g++ ne:
error: cast from 'void*' to 'int' loses precision
A pointer can be explicitly converted to any integral type large enough to hold it. The mapping function is implementation-defined [Note: it is intended to be unsurprising to those who know the addressing structure of the underlying machine. ]
Nevím, co je na přetypování nedefinovaného - chová se jasně.
Určitě? A jak?
Tiskni
Sdílej:
ISSN 1214-1267, (c) 1999-2007 Stickfish s.r.o.