LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 07-23-2007, 04:57 PM   #1
Grife
Member
 
Registered: Oct 2006
Location: Finland
Distribution: openSUSE
Posts: 89

Rep: Reputation: 15
g++: No 64bit programs compiled, 32bit instead?


Code:
[grifer@xoxxbox code]$ ./list_tietotyyppi 
Size of 'int' is:               4 bytes.
Size of 'short int' is:         2 bytes.
Size of 'long int' is:          4 bytes.
Size of 'char' is:              1 bytes.
Size of 'float' is:             4 bytes.
Size of 'double' is:            8 bytes.
This is output of a small training program that does just that: outputs the amount of bytes each "tietotyyppi" (I would be grateful to know what that is in english ) contains.
Funny thing is that I compiled the exact same code on iBook & PS3 and result was exactly the same. I know that iBook has 32bit processor whereas YDL on PS3 has 32bit userland on top of 64bit kernel. I assumed, that output would be different for 64bit architecture (book said it that output often looks different on different archs).
Could it be that I'm using <iostream> that is actually 32bit?
It's not that dangerous, I'm just learning to code but this is bugging me now.



Here's the code with my comments, funny little program:
Code:
/* program lists all diffrerent "tietotyypit", no clue what it could be in english.
gotta find out. 
something to do with how much memory each variable is going to use in a function.*/

#include <iostream>
using std::cout;

int main()
{
    cout << "Size of 'int' is:\t\t"     << sizeof(int)      << " bytes.\n";
    cout << "Size of 'short int' is:\t\t"   << sizeof(short)    << " bytes.\n";
    cout << "Size of 'long int' is:\t\t"    << sizeof(long)     << " bytes.\n";
    cout << "Size of 'char' is:\t\t"    << sizeof(char)     << " bytes.\n";
    cout << "Size of 'float' is:\t\t"   << sizeof(float)    << " bytes.\n";
    cout << "Size of 'double' is:\t\t"  << sizeof(double)   << " bytes.\n";
return 0;
}

Last edited by Grife; 07-23-2007 at 04:59 PM.
 
Old 07-23-2007, 07:39 PM   #2
ta0kira
Senior Member
 
Registered: Sep 2004
Distribution: FreeBSD 9.1, Kubuntu 12.10
Posts: 3,078

Rep: Reputation: Disabled
A 32-bit toolchain compiles 32-bit regardless of the kernel being used. Only a 64-bit native compiler or a 32-bit -> 64-bit cross-compiler will do what you are looking for. The main reason for this is that gcc is built around an asm spec for the machine the code needs to run on. This also means that in 32-bit "userland" all of the shared libraries are 32-bit.

A 64-bit kernel does you little good when your distro is 32-bits. The least you can expect is compilation errors in certain instances when a configuration script expects to find a cross-compiler, or finds a 32-bit compiler unsuitable for a 64-bit kernel. The only way to take advantage of the 64-bit kernel is to have 64-bit libraries or statically-link your binaries using a cross-toolchain.
ta0kira
 
Old 07-23-2007, 07:53 PM   #3
ta0kira
Senior Member
 
Registered: Sep 2004
Distribution: FreeBSD 9.1, Kubuntu 12.10
Posts: 3,078

Rep: Reputation: Disabled
Just out of curiosity, what is the full output of gcc -v?
ta0kira
 
  


Reply

Tags
c++, coding


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can I use to go from 32bit to 64bit? shame Linux - Distributions 6 11-03-2006 06:24 PM
can 64bit processor run both 64bit and 32bit computers? DJOtaku Linux - General 4 09-08-2005 08:14 PM
64bit or 32bit ginger.fish0 Ubuntu 3 09-01-2005 05:12 PM
32Bit or 64Bit? bchivers Mandriva 9 05-22-2005 12:28 PM
32bit to 64bit kirk1975 Linux - Newbie 1 10-20-2004 05:14 AM


All times are GMT -5. The time now is 09:08 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration