enable 64bit long type for gcc


 
Thread Tools Search this Thread
Top Forums Programming enable 64bit long type for gcc
# 1  
Old 12-19-2008
enable 64bit long type for gcc

hey, I believe I once saw a post in this forum, about enable an GCC option to enable long types. I simply cannot find it any more. Can anybody give me a hint? I am on 32bit Ubuntu, and I would like my int be really long. Also I need malloc() take long int argument too.

I found it is necessary to have really long types to use GNU C library time.h functions since the seconds since epoch is too long.
# 2  
Old 12-19-2008
Do you mean enable the long long datatype? gcc supports that by default, when configure runs during gcc install it turns off support for long long if the system does not support it.

Or do you want a 64 bit executable?
# 3  
Old 12-19-2008
gcc does have a -mlong64 option, but only for MIPS processors. long long datatypes should be 64-bit on most 32-bit processors, while long should already be 64-bit on 64-bit processors.
# 4  
Old 12-19-2008
not sure

hey, jim, thanks for reply. I am not sure 64bit executable is what I want since I am using a 32 bit machine Smilie.

I experienced a lots of error while using gnu c library time.h functions, where time_t type variable is used a lot. Wierd enough, say in my main() I get a time_t tim=1230768000 returned by localtime(). And I pass it to a function A(time_t tim). Inside the A() I see tim become negative value!!!

Hopefully I expressed the problem clearly Smilie!

Thanks for your reply.
# 5  
Old 12-19-2008
time_t ought to be time_t, you shouldn't need special datatypes other than time_t itself to deal with it. That means you shouldn't try to feed it through a long or an int either, always use the time_t datatype. The negative numbers are an artifact from converting a large unsigned number into a signed one.
# 6  
Old 12-19-2008
I ran this in a 32 bit executable under ubuntu:

Code:
#include <sys/types.h>
#include <stdio.h>

void foo(time_t t)
{
	printf("%u\n", t); 
	printf("%d\n", t);
}

int main()
{
	time_t tim=1230768000;
	foo(tim);
	return 0;
}

This is what I got:
Code:
/home/jmcnama> a.out
1230768000
1230768000

You have a coding problem not a datatype problem. Can you post the shortest possible chunk of code that shows your problem?
# 7  
Old 12-20-2008
Hey, Jim, thanks for the tip, it is really encouraging! You are right, it is not a problem of size of the storage. It is my program error. My unfinished makefile didn't automatically delete the old library I generated before linking, and leads to prototype mismatch from signed type to unsigned type. And I am totally lost while playing with long int, long long int and other datatypes while the old library file is there! Thanks!
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Extracting LONG Data Type from DB via UNIX Script

Hi, I want to extract a XML file which is stored in the database having a data Type as "LONG" via UNIX Scripting. But when i am triggering the SQL via UNIX it is fetching only the first Line and not the complete XML. Can you please suggest if the parameters that i have used needs any... (2 Replies)
Discussion started by: Barbara1234
2 Replies

2. Shell Programming and Scripting

Extracting LONG Data Type from DB via UNIX Script

Hi, I want to extract a XML file which is stored in the database having a data Type as "LONG" via UNIX Scripting. But when i am triggering the SQL via UNIX it is fetching only the first Line and not the complete XML. Can you please suggest if the parameters that i have used needs any... (0 Replies)
Discussion started by: dear_abhi2007
0 Replies

3. Red Hat

How to enable AIO and DIO on rhel5 64bit?

Hi Friends, Please help me to understand, how to enable async disk IO and Direct disk IO in ext3 filesystem on rhel5. Regards, Arumon (0 Replies)
Discussion started by: arumon
0 Replies

4. Programming

Problem FETCHing Long data type using CURSOR

Currently my Pro*c program is fetching a cloumn which is defined as LONG in oracle db. The data in the column is around 65k. But when I am FETCHing it to a varchar variable, I am only getting 22751 bytes of data using cursor. Is there any limitation on the data which is fetched by a cursor in... (2 Replies)
Discussion started by: manbt
2 Replies

5. Programming

gcc 4.3.2 accept sys call warrning incompatible pointer type

Hi all, this warning is driving me nuts. I use -pedantic with -Wall and -Werror so this needs to be fixed. BUILD: GNU-Linux-x86 Any ideas? struct sockaddr_in server_addr; int addr_len = sizeof (server_addr); fd = accept(link->socket_fd, (struct sockaddr_in *)... (2 Replies)
Discussion started by: personificator
2 Replies

6. Solaris

Installing gcc - recieve error message gcc : cannot execute

AIM- Install Oracle 11g on Solaris using VMWare Steps 1.Logged on as root 2.Created subfolders à /usr/local/bin & /usr/local/bin/gcc 3.Downloaded gcc & libiconv & unzipped them on my harddrive & burnt them on CD 4.Copied files from CD to /usr/local/bin/gcc 5.Terminal (root) à pkgadd -d... (8 Replies)
Discussion started by: Ackers
8 Replies

7. Programming

array type has incomplete element type

Dear colleagues, One of my friend have a problem with c code. While compiling a c program it displays a message like "array type has incomplete element type". Any body can provide a solution for it. Jaganadh.G (1 Reply)
Discussion started by: jaganadh
1 Replies

8. Shell Programming and Scripting

String type to date type

Can one string type variable changed into the date type variable. (1 Reply)
Discussion started by: rinku
1 Replies

9. UNIX for Dummies Questions & Answers

32bit vs 64bit

Whats the difference between 32bit and 64bit OS's or applications. I understand it a little but its just not clicking the way the teacher explained to me thanks, any info would be much appreciated (1 Reply)
Discussion started by: eloquent99
1 Replies
Login or Register to Ask a Question