С автодополнением я понял, почему у меня не работает.
Он показывает всё, что есть в текущей области видимости. При моём способе объявления она куда больше - туда в т.ч. попадают все объекты, которые имеют глобальную область видимости.
Переписал на явное указание области, стало приятнее:
За мультик спасибо :-)
У меня теперь другой вопрос, слегка поважнее.
В прошлый раз как-то просмотрел, что дебаг-версия прошивки увеличилась аж на 40 килобайт.
Эффект проявляется при добавлении в проект этих строк:
Код
struct SpiProps
{
static const STM32::SPI::SpiNum NUMBER = STM32::SPI::SPI_1;
static const STM32::SPI::Remap REMAP = STM32::SPI::REMAP_NONE;
static const STM32::SPI::Divisor InitialDivisor = STM32::SPI::SPI_DIV_2; // BusClk = 9 MHz, SPI clock = 4.5 MHz
static const STM32::SPI::Cpol InitialCPOL = STM32::SPI::CPOL_L;
static const STM32::SPI::Cpha InitialCPHA = STM32::SPI::
};
STM32::SPI::Spi<SpiProps> AccSPI;
Что особенно непонятно, эти +40кило появляются только с опцией компилятора -Og. Все остальные уровни оптимизации (-O1, -O2, -O3, -Os) работают нормально, размер бинарника возрастает на адекватную величину.
Сравнение map'ов показывает появление следующих функций при добавлении класса SPI:
CODE
.text 0x08004168 0x88c0 c:/program files/gnu tools arm embedded/4.9 2015q1/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/lib/armv7-m\libstdc++_nano.a(cp-demangle.o)
0x0800c944 __cxa_demangle
0x0800ca04 __gcclibcxx_demangle_callback
.text 0x0800ca28 0x14 c:/program files/gnu tools arm embedded/4.9 2015q1/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/lib/armv7-m\libg_nano.a(lib_a-strcmp.o)
0x0800ca28 strcmp
.text.sprintf 0x0800d34c 0x20 ./Libraries/printf-stdarg.o
0x0800d34c sprintf
.text._exit 0x0800d36c 0x4 ./Libraries/syscalls.o
0x0800d36c _exit
.text._close 0x0800d370 0x8 ./Libraries/syscalls.o
0x0800d370 _close
.text._fstat 0x0800d378 0xc ./Libraries/syscalls.o
0x0800d378 _fstat
.text._getpid 0x0800d384 0x4 ./Libraries/syscalls.o
0x0800d384 _getpid
.text._isatty 0x0800d388 0x18 ./Libraries/syscalls.o
0x0800d388 _isatty
.text._kill 0x0800d3a0 0x10 ./Libraries/syscalls.o
0x0800d3a0 _kill
.text._lseek 0x0800d3b0 0x4 ./Libraries/syscalls.o
0x0800d3b0 _lseek
.text._sbrk 0x0800d3b4 0x3c ./Libraries/syscalls.o
0x0800d3b4 _sbrk
.text._read 0x0800d3f0 0x34 ./Libraries/syscalls.o
0x0800d3f0 _read
.text._write 0x0800d424 0x4c ./Libraries/syscalls.o
0x0800d424 _write
.text._ZN5STM323SPI3SpiINS0_8SpiPropsEE5BufRwEPhPKhj
0x0800e750 0xbc ./Drivers/Accelerometer.o
0x0800e750 STM32::SPI::Spi<STM32::SPI::SpiProps>::BufRw(unsigned char*, unsigned char const*, unsigned int)
.text._ZN5STM323SPI3SpiINS0_8SpiPropsEE6HwInitEv
0x0800e860 0x58 ./Drivers/Accelerometer.o
0x0800e860 STM32::SPI::Spi<STM32::SPI::SpiProps>::HwInit()
.text._Z41__static_initialization_and_destruction_0ii
0x0800e8b8 0x34 ./Drivers/Accelerometer.o
.text._GLOBAL__sub_I_AccSPI
0x0800e8ec 0x10 ./Drivers/Accelerometer.o
.text._ZN10__cxxabiv111__terminateEPFvvE
0x0800f064 0x8 c:/program files/gnu tools arm embedded/4.9 2015q1/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/lib/armv7-m\libstdc++_nano.a(eh_terminate.o)
0x0800f064 __cxxabiv1::__terminate(void (*)())
.text._ZSt13get_terminatev
0x0800f06c 0x10 c:/program files/gnu tools arm embedded/4.9 2015q1/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/lib/armv7-m\libstdc++_nano.a(eh_terminate.o)
0x0800f06c std::get_terminate()
.text._ZSt9terminatev
0x0800f07c 0xa c:/program files/gnu tools arm embedded/4.9 2015q1/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/lib/armv7-m\libstdc++_nano.a(eh_terminate.o)
0x0800f07c std::terminate()
*fill* 0x0800f086 0x2
.text._ZN9__gnu_cxx27__verbose_terminate_handlerEv
0x0800f088 0x98 c:/program files/gnu tools arm embedded/4.9 2015q1/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/lib/armv7-m\libstdc++_nano.a(vterminate.o)
0x0800f088 __gnu_cxx::__verbose_terminate_handler()
.text.__cxa_current_exception_type
0x0800f120 0x1a c:/program files/gnu tools arm embedded/4.9 2015q1/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/lib/armv7-m\libstdc++_nano.a(eh_type.o)
0x0800f120 __cxa_current_exception_type
*fill* 0x0800f13a 0x2
.text.__cxa_get_globals
0x0800f13c 0x8 c:/program files/gnu tools arm embedded/4.9 2015q1/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/lib/armv7-m\libstdc++_nano.a(eh_globals.o)
0x0800f13c __cxa_get_globals
.text.abort 0x0800f144 0xe c:/program files/gnu tools arm embedded/4.9 2015q1/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/lib/armv7-m\libg_nano.a(lib_a-abort.o)
0x0800f144 abort
*fill* 0x0800f152 0x2
.text._fputs_r
0x0800f154 0xa8 c:/program files/gnu tools arm embedded/4.9 2015q1/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/lib/armv7-m\libg_nano.a(lib_a-fputs.o)
0x0800f154 _fputs_r
.text.fputs 0x0800f1fc 0x14 c:/program files/gnu tools arm embedded/4.9 2015q1/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/lib/armv7-m\libg_nano.a(lib_a-fputs.o)
0x0800f1fc fputs
.text.realloc 0x0800f258 0x14 c:/program files/gnu tools arm embedded/4.9 2015q1/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/lib/armv7-m\libg_nano.a(lib_a-realloc.o)
0x0800f258 realloc
.text._raise_r
0x0800f26c 0x50 c:/program files/gnu tools arm embedded/4.9 2015q1/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/lib/armv7-m\libg_nano.a(lib_a-signal.o)
0x0800f26c _raise_r
.text.raise 0x0800f2bc 0x10 c:/program files/gnu tools arm embedded/4.9 2015q1/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/lib/armv7-m\libg_nano.a(lib_a-signal.o)
0x0800f2bc raise
.text._kill_r 0x0800f2cc 0x24 c:/program files/gnu tools arm embedded/4.9 2015q1/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/lib/armv7-m\libg_nano.a(lib_a-signalr.o)
0x0800f2cc _kill_r
.text._getpid_r
0x0800f2f0 0x4 c:/program files/gnu tools arm embedded/4.9 2015q1/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/lib/armv7-m\libg_nano.a(lib_a-signalr.o)
0x0800f2f0 _getpid_r
.text.__swbuf_r
0x0800f338 0xa8 c:/program files/gnu tools arm embedded/4.9 2015q1/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/lib/armv7-m\libg_nano.a(lib_a-wbuf.o)
0x0800f338 __swbuf_r
.text.__swsetup_r
0x0800f3e0 0xd8 c:/program files/gnu tools arm embedded/4.9 2015q1/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/lib/armv7-m\libg_nano.a(lib_a-wsetup.o)
0x0800f3e0 __swsetup_r
.text.__sflush_r
0x0800f4b8 0x106 c:/program files/gnu tools arm embedded/4.9 2015q1/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/lib/armv7-m\libg_nano.a(lib_a-fflush.o)
0x0800f4b8 __sflush_r
*fill* 0x0800f5be 0x2
.text._fflush_r
0x0800f5c0 0x54 c:/program files/gnu tools arm embedded/4.9 2015q1/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/lib/armv7-m\libg_nano.a(lib_a-fflush.o)
0x0800f5c0 _fflush_r
.text._cleanup_r
0x0800f614 0xc c:/program files/gnu tools arm embedded/4.9 2015q1/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/lib/armv7-m\libg_nano.a(lib_a-findfp.o)
0x0800f614 _cleanup_r
.text.std.isra.0
0x0800f620 0x48 c:/program files/gnu tools arm embedded/4.9 2015q1/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/lib/armv7-m\libg_nano.a(lib_a-findfp.o)
.text.__sfmoreglue
0x0800f668 0x2c c:/program files/gnu tools arm embedded/4.9 2015q1/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/lib/armv7-m\libg_nano.a(lib_a-findfp.o)
0x0800f668 __sfmoreglue
.text.__sinit 0x0800f694 0x60 c:/program files/gnu tools arm embedded/4.9 2015q1/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/lib/armv7-m\libg_nano.a(lib_a-findfp.o)
0x0800f694 __sinit
.text.__sfp 0x0800f6f4 0x74 c:/program files/gnu tools arm embedded/4.9 2015q1/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/lib/armv7-m\libg_nano.a(lib_a-findfp.o)
0x0800f6f4 __sfp
.text._fwalk_reent
0x0800f768 0x3c c:/program files/gnu tools arm embedded/4.9 2015q1/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/lib/armv7-m\libg_nano.a(lib_a-fwalk.o)
0x0800f768 _fwalk_reent
.text.__smakebuf_r
0x0800f7a4 0x98 c:/program files/gnu tools arm embedded/4.9 2015q1/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/lib/armv7-m\libg_nano.a(lib_a-makebuf.o)
0x0800f7a4 __smakebuf_r
.text._free_r 0x0800f83c 0x88 c:/program files/gnu tools arm embedded/4.9 2015q1/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/lib/armv7-m\libg_nano.a(lib_a-nano-freer.o)
0x0800f83c _free_r
.text._malloc_r
0x0800f8c4 0xac c:/program files/gnu tools arm embedded/4.9 2015q1/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/lib/armv7-m\libg_nano.a(lib_a-nano-mallocr.o)
0x0800f8c4 _malloc_r
.text._realloc_r
0x0800f970 0x4c c:/program files/gnu tools arm embedded/4.9 2015q1/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/lib/armv7-m\libg_nano.a(lib_a-nano-reallocr.o)
0x0800f970 _realloc_r
.text._sbrk_r 0x0800f9bc 0x20 c:/program files/gnu tools arm embedded/4.9 2015q1/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/lib/armv7-m\libg_nano.a(lib_a-sbrkr.o)
0x0800f9bc _sbrk_r
.text.__sread 0x0800f9dc 0x22 c:/program files/gnu tools arm embedded/4.9 2015q1/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/lib/armv7-m\libg_nano.a(lib_a-stdio.o)
0x0800f9dc __sread
.text.__swrite
0x0800f9fe 0x38 c:/program files/gnu tools arm embedded/4.9 2015q1/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/lib/armv7-m\libg_nano.a(lib_a-stdio.o)
0x0800f9fe __swrite
.text.__sseek 0x0800fa36 0x24 c:/program files/gnu tools arm embedded/4.9 2015q1/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/lib/armv7-m\libg_nano.a(lib_a-stdio.o)
0x0800fa36 __sseek
.text.__sclose
0x0800fa5a 0x8 c:/program files/gnu tools arm embedded/4.9 2015q1/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/lib/armv7-m\libg_nano.a(lib_a-stdio.o)
0x0800fa5a __sclose
*fill* 0x0800fa62 0x2
.text._write_r
0x0800fa64 0x24 c:/program files/gnu tools arm embedded/4.9 2015q1/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/lib/armv7-m\libg_nano.a(lib_a-writer.o)
0x0800fa64 _write_r
.text._close_r
0x0800fa88 0x20 c:/program files/gnu tools arm embedded/4.9 2015q1/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/lib/armv7-m\libg_nano.a(lib_a-closer.o)
0x0800fa88 _close_r
.text._fstat_r
0x0800faa8 0x24 c:/program files/gnu tools arm embedded/4.9 2015q1/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/lib/armv7-m\libg_nano.a(lib_a-fstatr.o)
0x0800faa8 _fstat_r
.text._isatty_r
0x0800facc 0x20 c:/program files/gnu tools arm embedded/4.9 2015q1/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/lib/armv7-m\libg_nano.a(lib_a-isattyr.o)
0x0800facc _isatty_r
.text._lseek_r
0x0800faec 0x24 c:/program files/gnu tools arm embedded/4.9 2015q1/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/lib/armv7-m\libg_nano.a(lib_a-lseekr.o)
0x0800faec _lseek_r
.text._malloc_usable_size_r
0x0800fb10 0x14 c:/program files/gnu tools arm embedded/4.9 2015q1/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/lib/armv7-m\libg_nano.a(lib_a-nano-msizer.o)
0x0800fb10 _malloc_usable_size_r
.text._read_r 0x0800fb24 0x24 c:/program files/gnu tools arm embedded/4.9 2015q1/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/lib/armv7-m\libg_nano.a(lib_a-readr.o)
0x0800fb24 _read_r
*(.rodata)
.rodata 0x0800fb48 0x738 c:/program files/gnu tools arm embedded/4.9 2015q1/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/lib/armv7-m\libstdc++_nano.a(cp-demangle.o)
Аналогично, эти функции пропадают при включении оптимизации (там, правда, сложнее понять - меняется размер всех функций, и линкер зачем-то меняет порядок сборки).
Что это?!