64 bit Porting Problem !!!


 
Thread Tools Search this Thread
Operating Systems Linux SuSE 64 bit Porting Problem !!!
# 1  
Old 01-01-2009
64 bit Porting Problem !!!

Dear All,

I am trying to build my code (currently functioning on 32bit) on 64 bit SUSE machine.
I am getting following error:

warning: initializer element is not computable at load time
dau.gss.c:275: error: initializer element is not constant
dau.gss.c:275: error: (near initialization for `type_hs.utility.n')

in dau.gss.c the content is :

line no. Code

...
...
272 static DH_T_HS ca_type_hs =
273 {0, DH_B_OID, 0, 0, ASN1_OID, 0, 3, 0, 0x55, 4, 37};
274 static DH_T_HS type_hs =
275 {(UINT32)&ca_type_hs, DH_B_OID, 0, 0, ASN1_OID, 0, 3, 0, 0x55, 4, 36};
...
...

Following are some definitions related to the above mentioned code:

typedef unsigned int UINT32;
typedef unsigned char OCTET;
typedef unsigned short UINT16;

typedef struct dh_t_hs {
union {
UINT32 n;
struct dh_t_hs *p;
} utility;

OCTET cntrl;
OCTET flags;
UINT16 use;
UINT16 id2;
UINT16 use2;
UINT32 count;
UINT32 count_lmt;

union {
OCTET id [4];
OCTET prime [4];
UINT32 list [1];
struct dh_t_hs *construct [1];
} content;
} DH_T_HS, *DH_P_HS;


If I make the "n" variable unsigned long (in union "utility" within structure dh_t_hs) and if in "type_hs" variable (@ line 275 in the file dau.gss.c) I do "(unsigned long)&ca_type_hs", I dont get the above mentioned error.

But the problem is that I cant make the "n" variable unsigned long (in union "utility" within structure "dh_t_hs") as it used widely in the project as an integer only.

Could anybody please suggest some solution for the same?

Thanks in advance.

Regards.
Thanks in advance.

Regards,
# 2  
Old 01-05-2009
You do realize that 64 bit architecture means 64-bit pointers, which means 8-byte pointers, which is the same size as an unsigned long, right?
Quote:
But the problem is that I cant make the "n" variable unsigned long (in union "utility" within structure "dh_t_hs") as it used widely in the project as an integer only.
Have you tried making it just a "long". Presumably the only reason you CANNOT use a signed long in place of a signed integer is that your code expects the integer to overflow at some point, or it purposefully shifts bits to the left and then expecting the 33rd bit to not be present.
# 3  
Old 01-08-2009
Hi otheus,

Thanx for your reply. Carefully looking at the code gave me idea that making that variable as unsigned long is harmless. So I made it as unsigned long.

I am facing another issue for which I need your help. Could you give me any idea about some compiler flags which give 64 bit porting specific warnings for LInux? For example in Solaris if I provide "CC +w2 -xarch=v9" it gives the 64 bit porting warnings, but I couldn't find any similar things for Linux. I am using "gcc" to build the project and the above mentioned flag is not working with this.

Thank you in advance.

Regards,
Saurabh
# 4  
Old 01-08-2009
Mostly all there is is "-march" option. I don't know about the -xarch option, but it looks specific to the SPARC hardware, not Solaris. Similarly, you want warnings specific to a 64-bit architecture, not Linux. Looking through the man pages, one will find references to Operating Systems being compiled on specific architectures. One thing you can do is use the "-mlong32" option which forces all "long" specifications and pointers to 32 bits. This might not be a problem unless you expect the program to require more than 32 bits of addressing space (IE, more than 4GB of memory).
# 5  
Old 01-09-2009
Hi Otheus,

You are right on the point that I want to know the architecture of the CPU. Doing "isainfo" on Solaris gives the CPU architecture but the command is not working on Linux. I also did "cat /proc/cpuinfo" but its not providing the architecture type which I could use in -march switch. Even in gcc manual i could not find the appropriate value.
To check the appropriate flags to get desired warnings I wrote a sample code which is as follows:

#include <iostream>

using namespace std;

int main()
{
unsigned long ul = ~1UL;
int i = 20,j;
int *ip = &i;
i = ul;
j = (int) ip;
return 1;
}

If I build the code on 64 bit machine I should get warnings for the following two lines:
i = ul;
j = (int) ip;
But when i copiled it with "gcc -c -m64 -Wall -Wmissing-prototypes" I am getting only one warning i.e. "warnings.cpp:11: warning: cast from pointer to integer of different size". I am not getting warning for long to int assignement for the line "i = ul;".
Could you suggest me something on this.


Regards,
Saurabh
# 6  
Old 01-09-2009
Your machine hardware is 64 bit, but is the OS? The code generated by -m64 depends on the "environment", not the actual hardware:
Code:
       -m64
           Generate code for a 32-bit or 64-bit environment.  The 32-bit envi-
           ronment sets int, long and pointer to 32 bits and generates code
           that runs on any i386 system.  The 64-bit environment sets int to
           32 bits and long and pointer to 64 bits and generates code for
           AMD's x86-64 architecture.

So type "uname -a" and "arch" to see what environment you are actually running under. If it's x86_64, then you are indeed on 64-bit. Otherwise, it's 32-bit.
# 7  
Old 01-12-2009
Yes ofcourse the OS is 64 bit. its x86_64.

Thats why I am wondering why it is not giving warning for long to int assignment.
uname -a gave following result:

Linux msglxd03 2.6.5-7.97-smp #1 SMP Fri Jul 2 14:21:59 UTC 2004 x86_64 x86_64 x86_64 GNU/Linux
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Solaris

Solaris 10 apache 64 bit libldap.so problem

Hello, I am fairly new to Solaris so please be gentle ;). I am trying to install apache 2.4.3 adapting a script one of my colleagues wrote for version 2.2.23. The problem lies in the fact that I am aiming at creating a 64bit package hence I've already amended the script to reflect that. I... (3 Replies)
Discussion started by: teotao
3 Replies

2. Red Hat

DB2 ODBC connectivity problem in RHEL5 32 bit

Hi, I installed Db2 9.7 on RHEL5 32bit . Instance Name is db2inst1 amd in that i created database as mydb. I exported env variables for classpath ,db2dir,db2instance LD_LIBRARY_PATH ,PATH ,ODBC, ODBCHOME ,ODBCINI My application needs ODBC connectivity and so I modified odbc.ini file . ... (0 Replies)
Discussion started by: roopalidalvi231
0 Replies

3. HP-UX

hpux-itanium 64 bit problem for libC

i am trying to build on hpux-itanium 64 bit platform. my application needs to link to 64 bit version of the library libCsup.so This library is present in /usr/lib/hpux64/libCsup.so I am specifying the location of this library as linker flags LDFLAGS := -Wl,-N -Wl,+s... (0 Replies)
Discussion started by: skyineyes
0 Replies

4. HP-UX

HP-Unix 64 bit Tape Drive creating problem

Hello All, I have HP Openview storage data protector version 5.5. When I am going to write my backup I have an error message saying "Connot Open Device /dev/rmt/0mn" Follownig is my output: # ls -l /dev/rmt/0mn crw-rw-rw- 2 bin bin 205 0x080140 Jan 17 16:41 /dev/rmt/0mn # uname -a... (2 Replies)
Discussion started by: hellozishan
2 Replies

5. HP-UX

Tru 64 bit on HP AlphaServer ES45 creating problem Help Needed !!!

Dear All, I am new on Tru 64 bit Unix platform. I have a database server "HP AlphaServer ES45" version p5.1 of Tru Ux 64 bit installed. I have 4 hard drives in this system (1,2,3,4). My 4th hard drive is damaged which contain Oracle database files including partitions on 4th drives... (2 Replies)
Discussion started by: hellozishan
2 Replies

6. Red Hat

No Error for 64-bit porting

I am just trying to get the warning while compiling for 64-bit on Linux >> uname -a Linux mms4.es.cpth.ie 2.6.9-22.ELsmp #1 SMP Mon Sep 19 18:00:54 EDT 2005 x86_64 x86_64 x86_64 GNU/Linux =================================== Written test.c file which conatin : #include<stdio.h>... (1 Reply)
Discussion started by: amit_27
1 Replies

7. Solaris

Porting C++ 32-bit code on 64-bit Solaris

Hi, I am trying to convert 32-bit code to 64-bit. I have defined function int main() { int* l; size_t len1; fun(len1); return 0; } void fun(int* ptr) { cout<<"\nsizeof(ptr)"<<sizeof(ptr); } However while compiling getting error as : Error: Formal argument ptr... (2 Replies)
Discussion started by: amit_27
2 Replies

8. UNIX for Dummies Questions & Answers

A bit of a problem with a UNIX based server.

Alright. As the title states, I'm working with a UNIX based web server(Sun Fire v120). The problem I'm currently having is trying to properly configure it for hosting. If anyone could help me out, it would be great. Much thanks. -XTIZ3 (2 Replies)
Discussion started by: XTIZ3
2 Replies

9. AIX

porting an application on 64-bit AIX version 5

Hi all, I am facing problem in porting to 64 bit AIX especially with compiling options to compile and run under 64 bit kernel.Can any one put some light on the issue thanks in advance vishal (14 Replies)
Discussion started by: vishalzone2002
14 Replies
Login or Register to Ask a Question