So I've begun using a library called Poco. My program doesn't do what its supposed to yet I've checked over everything.

The code is:

#include "stdafx.h"
#include <iostream>
#include <Poco/Debugger.h>
#include <string.h>

std::string endianness = "Host byte order is Little Endian.\n";
std::string endianness = "Host byte order is Big Endian.\n";
#ifdef POCO_LONG_IS_64_BIT 
std::string bit_arch = "Host architecture is x64.\n";
std::string bit_arch = "x86 host architecture.\n";

int main( )
    std::string a;
    long long int b = 0;
    if ( Poco::Debugger::isAvailable() ) { std::cout << "Debugging capability is available.\n"; }
    std::cout << bit_arch;
    std::cout << endianness;
    std::cout << "Size of the long int (b): " << sizeof(b) <<"\n";
    std::cin >> a;

    return 0;

When it runs it says that I have a x86 processor, yet I do not. I installed a 64 bit processor myself many months ago. I just don't understand why it says that because I've made sure there aren't any logical errors that I can see. Everything except that works just fine. Maybe I'm missing something.

Edited by Curious Gorge: removed boldness

3 Years
Discussion Span
Last Post by Curious Gorge

I would assume that POCO_LONG_IS_64_BIT detects if the size of the type long or int. Usually, on 64bit platforms, the int type is still 4 bytes (32bit), it's only that pointers are 64bit (to allow more than 4Gb of RAM) and that there are 64bit registers available natively (which could accommodate 64bit integers without having to break them up).

So, the logic error here is that you assumed that a 64bit platform necessarily means 64bit integers. Most compilers will not generate 64bit integers (unless it's long long int). Also, a 64bit platform does not necessarily imply that the memory is aligned on 8 byte boundaries, in fact, I don't think that it ever is, and therefore, 4 bytes is really the ideal size for an integer that doesn't necessarily need to be that big, i.e., for int or long.


Ah, yes that does make sense. I thought I must have assumed 64bit longs meant it was a 64 bit architecture but I was not sure. Thank you!

**[EDIT] ** Hey I was just going a bit further into the poco documentation and came across this: http://pocoproject.org/slides/050-PlatformAndEnvironment.pdf as it turns out there are macros for determining what kind of architecture your code is running on. I was just using the wrong macro/header.

Edited by Curious Gorge: Added [edit]

Votes + Comments
Thanks for taking the trouble to add the macro note
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.