S60 Open C
Compilers and IDEs Using Open C

Compilers and IDEs Using Open C

Table of Contents

How to promote char in comparison with RVCT

 


How to promote char in comparison with RVCT

The default char will be promoted to int on WINSCW and unsigned on the RVCT compiler. Due to this promotion, comparison c != EOF will not become true on hardware and it will loop infinite.

RVCT treats plain char type as unsigned by default. There is a command line option "--signed_chars" that forces RVCT to treat plain char type as a signed char. Using this option, the example will compile and run the way it is expected to. But this option must be applied with care, since using the switch universally may have other ramifications elsewhere in the source base.

The MMP file can be modified as:

OPTION armcc  --signed_chars

Example:

#include <stdio.h>
int main()
{
  FILE *fp;
  char c;
  fp=fopen("test.txt","w"); 
  fprintf(fp,"%s","ab");
  fclose(fp);
  fp=fopen("test.txt","r"); 
  c=getc(fp);
  while(c != EOF)
  {
     c = getc(fp);
  }
  printf("\nOut of loop");
  fclose(fp);
  getchar();
}

Give feedback of this section


©Nokia 2007

Back to top


This material, including documentation and any related computer programs, is protected by copyright controlled by Nokia. All rights are reserved. Copying, including reproducing, storing, adapting or translating, any or all of this material requires the prior written consent of Nokia. This material also contains confidential information, which may not be disclosed to others without the prior written consent of Nokia.

Nokia is a registered trademark of Nokia Corporation. S60 and logo is a trademark of Nokia Corporation. Java and all Java-based marks are trademarks or registered trademarks of Sun Microsystems, Inc. Other company and product names mentioned herein may be trademarks or tradenames of their respective owners.