Keil Logo

ARMCC: Error #268: declaration may not appear after executable state

Information in this knowledgebase article applies to:

  • MDK-ARM V5.13 and later


While compiling a module, this error message displays:

Error: #268: declaration may not appear after executable statement in block


Keil C compilers are based on ANSI C C90 standard, but are expanded with added language extensions, practical concessions to the architectural peculiarities of the microcontrollers, and other features that meet the needs of embedded systems programmers.

In C90, all variable declarations must happen before any executable statements in a function or other code block. The compiler error message mentions the line number of the offending line of code.


  1. Make sure the compiler included the correct header files (if the variable and function definitions were in there).
  2. Place variable definition(s) or add a function prototype before the executable code. See any C coding guide for more details.
  3. C99 enables you to mix declarations and statements within compound statements, like in C++. Turn on C99 mode in the Keil IDE under Project → Options for Target → C/C++ tab, and check C99 Mode. Read more about the --c99 compiler switch here.
  4. If using inline or embedded assembly, make sure to follow the correct syntax.


Last Reviewed: Tuesday, September 27, 2016

Did this article provide the answer you needed?
Not Sure
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.