Namespaces

Variants
Actions

Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.

How to promote char in comparison with RVCT

From Wiki
Jump to: navigation, search
Article Metadata
Article
Created: polaka_sr (13 Jun 2008)
Last edited: hamishwillee (27 Jul 2012)

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 Code:

#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();
}
This page was last modified on 27 July 2012, at 04:19.
27 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×