Keil Logo

GENERAL: LONG UNSIGNED GENERATES SYNTAX ERROR


Information in this article applies to:

  • C166 Version 3.12
  • C166 Version 4.03
  • C251 Version 2.14
  • C51 Version 5.50

SYMPTOMS

If I declare a variable as:

long unsigned x;

I get a syntax error when I compile my file. This should be accepted since unsigned long is a valid type.

CAUSE

According to the ANSI C Standard, section 6.5.2 Type Specifiers (ANSI/ISO 9899-1990), only the following are valid type specifiers (comma separated sets designate the same type):

  • void
  • char
  • signed char
  • unsigned char
  • short, signed short, short int, or signed short int
  • unsigned short, or unsigned short int
  • int, signed, signed int, or no type specifiers
  • unsigned, or unsigned int
  • long, signed long, long int, or signed long int
  • unsigned long, or unsigned long int
  • float
  • double
  • long double
  • struct-or-union specifier
  • enum-specifier
  • typedef-name

Since long unsigned is not included in the list, it is not a valid type specifier and results in a syntax error. Use unsigned long in your program.

MORE INFORMATION

  • Refer to the ANSI C Standard, section 6.5.2 Type Specifiers (ANSI/ISO 9899-1990) for more information.

Last Reviewed: Monday, October 11, 2004


Did this article provide the answer you needed?
 
Yes
No
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.