All shutdown and ready to go....

The office move is on, my desktop has been shutdown and is moving as I type. Obviously I'm on a laptop to do this.

Now the type promotion feature has been resolved my port to Amd 64 is nearly done. The surpise has been how many warnings gcc is reporting which the Sun C compiler and lint are happy with, and gcc is happy with in 32 bit land. All are around casting of values so I guess I deserve it. gcc is particularly sensitive to casting types that are smaller than a pointer into a pointer, eg:

        char x;
        char \*p;
 
        p = (char \*)x;

Results in the error:

foo.c:10: warning: cast to pointer from integer of different size

Mine are all type int not type char which shows up the problem with a LP64 system but not on an ILP32 system. So I have some work to clean a few of these, up so it will build cleanly both with the Sun C compiler and gcc in both 32 and 64 bit. Nice to see from Google that I am not alone is getting these warnings.

Comments:

Hi Chris, When you do the following: char x; char \*p; p = (char \*)x; Does the type cast tell gcc that x is a pointer to a char, and place the address of that pointer in p? Thanks, - Matty

Posted by Matty on September 17, 2004 at 11:19 AM BST #

char x; 
char \*p; 
p = (char \*)x; 
This does not cast x to be the address of x, for that you need &x and would not need the cast. My programming problem is a result of storing non pointer data in a pointer.

Posted by Chris Gerhard on September 20, 2004 at 10:22 AM BST #

Post a Comment:
Comments are closed for this entry.
About

This is the old blog of Chris Gerhard. It has mostly moved to http://chrisgerhard.wordpress.com

Search

Archives
« April 2014
MonTueWedThuFriSatSun
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
    
       
Today