According to documentation RealView Compilation Tools Compiler User's Guide (version 3.1) Compound literals
int y[] = (int []) {1, 2, 3};
--c90 mode
warning #520-D initialization with "(...)" expected for aggregated object error #70 incomplate type is not allowed error #29 expected an expression
--c99 mode
warning #520-D initialization with "(...)" expected for aggregated object error #144 a value of type "int *" cannot be used to initialize an entity of type "int"
it must be compiled ok, but it is not. What's wrong?
You've left off the comment that is in the documentation:
int y[] = (int []) {1, 2, 3}; // error in strict C99, okay in C99 --gnu
What you are seeing is consistent with the comment. Some things that are illegal in C99 are nonetheless accepted with --c99 --gnu.
This usage is legal C99:
int *yp = (int []) {1, 2, 3};
This usage is legal in C90, C99 and C++:
int y[] = {1, 2, 3};
Thanks it's work with --gnu compiler directive. I don't know what documentation do you read. My sources is: infocenter.arm.com/.../index.jsp http://www.keil.com/support/man/docs/armcc/armcc_BABECCFG.htm And there are no mentions about --gnu option. quote from documentation ISO C99 supports compound literals.
I don't know what documentation do you read.
I was looking in the Realview 3.1 documentation: infocenter.arm.com/.../index.html (which is marked "Superseded" because there are newer versions of the tools)
My sources is: infocenter.arm.com/.../index.jsp
That page also says "Supported in GNU mode for C only." and "Withdrawn" (in the background watermark).
Compound literals are a C99 feature, but in C99 they cannot be used to initialize arrays that way (which is reasonable since there is a similar, older way to initialize arrays). GNU allows using compound literals to initialize arrays as an extention to C99. And armcc allows the extension when in --gnu mode.
ARM C/C++ Compiler 4.1 Build 894
I have some problem with compiler directive --info=totals
1)when i use it in cmd.exe window it's work fine
c:\>cd keil450 c:\Keil450>cd arm c:\Keil450\ARM>cd bin40
c:\Keil450\ARM\BIN40>armcc -c --cpu Cortex-M3 --info=totals c:\src.c
Code (inc. data) RO Data RW Data ZI Data Debug File Name
18 0 0 0 0 84 src.o
c:\Keil450\ARM\BIN40>
2) But if i try to use it with IDE it's not working Project Options -> c/c++ -> Misc Controls: --info=totals Rebuild all
Build target 'Osilogreph Test' compiling system_stm32f10x.c... compiling main.c... compiling stm32f10x_rcc.c... compiling stm32f10x_flash.c... compiling stm32f10x_gpio.c... compiling stm32f10x_tim.c... compiling misc.c... linking... Program Size: Code=2080 RO-data=320 RW-data=44 ZI-data=1636 "OSCTest.axf" - 0 Error(s), 0 Warning(s).
But where is code metrics ??? maby its don't work with Windows 7 64 bit version