|
1 <?xml version="1.0" encoding="utf-8"?> |
|
2 <!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. --> |
|
3 <!-- This component and the accompanying materials are made available under the terms of the License |
|
4 "Eclipse Public License v1.0" which accompanies this distribution, |
|
5 and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". --> |
|
6 <!-- Initial Contributors: |
|
7 Nokia Corporation - initial contribution. |
|
8 Contributors: |
|
9 --> |
|
10 <!DOCTYPE concept |
|
11 PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd"> |
|
12 <concept id="GUID-189DA86A-BA77-4314-9597-E3C92B3C82D9" xml:lang="en"><title>Promoting <codeph>char</codeph> in |
|
13 comparison with RVCT</title><shortdesc>The default <codeph>char</codeph> will be promoted to <codeph>int</codeph> on <codeph>WINSCW</codeph> and <codeph>unsigned</codeph> on |
|
14 the RVCT compiler. Due to this promotion, comparison c != EOF will not become |
|
15 true on hardware and it will loop infinite. </shortdesc><prolog><metadata><keywords/></metadata></prolog><conbody> |
|
16 <p>RVCT treats plain <codeph>char</codeph> type as <codeph>unsigned</codeph> by |
|
17 default. There is a command line option "<codeph>--signed_chars</codeph>" |
|
18 that forces RVCT to treat plain char type as a signed char. Using this option, |
|
19 the example will compile and run the way it is expected to. But |
|
20 this option must be applied with care, since using the switch universally |
|
21 may have other ramifications elsewhere in the source base.</p> |
|
22 <p>The MMP file can be modified as: </p> |
|
23 <codeblock xml:space="preserve">OPTION armcc --signed_chars</codeblock> |
|
24 <p>Example: </p> |
|
25 <codeblock xml:space="preserve">#include <stdio.h> |
|
26 int main() |
|
27 { |
|
28 FILE *fp; |
|
29 char c; |
|
30 fp=fopen("test.txt","w"); |
|
31 fprintf(fp,"%s","ab"); |
|
32 fclose(fp); |
|
33 fp=fopen("test.txt","r"); |
|
34 c=getc(fp); |
|
35 while(c != EOF) |
|
36 { |
|
37 c = getc(fp); |
|
38 } |
|
39 printf("\nOut of loop"); |
|
40 fclose(fp); |
|
41 getchar(); |
|
42 } |
|
43 </codeblock> |
|
44 </conbody></concept> |