LPCxpresso: Potize s optimalizaci
Jan Waclawek
konfera na efton.sk
Středa Červenec 27 23:22:23 CEST 2016
Potiaz s normou je ta, ze jedna vec je roztahana krizom-krazom po viacerych
miestach (tak ako to vlastne byva aj v netrivialnych neucebnicovych
programoch :-). Preto mi aj chvilu trvalo, kym som to nasiel (budem sa
drzat C99 bo C11 nemam dobre nastudovane priznavam bez mucenia).
Takze citovali ste najprv 6.2.2#5
If the declaration of an identifier for an object has file scope and no
storage-class specifier, its linkage is external.
Inaksie povedane, ak je v subore *deklaracia* (co moze byt aj definiciou
ale nemusi) premennej (co je zhruba object) a nie je k nemu pripisane
jedno z "typedef, extern, static, auto, register", tak sa to meno objavi v
prelozenom binarnom objekte, ci uz so znackou ze k nemu treba alokovat
miesto alebo nie.
Potom ste citovali 6.2.2#2
In the set of translation units and libraries that constitutes an entire
program, each declaration of a particular identifier with external linkage
denotes the same object or
function.
Inaksie povedane, ak linker zacne linkovat, tak vsetky tieto mena, aj ked
pochadzaju z roznych suborov, maju ukazovat na tu istu adresu. Potial
dobre.
Lenze je tu este aj 6.9#3:
An external definition is an external declaration that is also a definition
of a function (other than an inline definition) or an object. If an
identifier declared with external
linkage is used in an expression (other than as part of the operand of a
sizeof operator whose result is an integer constant), somewhere in the
entire program there shall be
exactly one external definition for the identifier; otherwise, there shall
be no more than one. 140)
Nie je to v constraints a je tam slovo shall, znamena to podla 4#2, ze ak
sa to porusi, spravanie je nedefinovane.
Nedefinovane spravanie pochopitelne zahrna aj "funguje podla ocakavania
(ale neda sa na to spolahnut)".
wek
Další informace o konferenci Hw-list