I'm writing code which will compile on multiple Windows and multiple *nix
platforms. Some will have 64-bit integers, I believe.
What is my best option to define platform-independent types such as UINT32
or UINT64? I'm not sure how to sort out the various platforms and integer
sizes, and some of it may even vary based on compiler options.
Thanks
--
David T. Ashley (dt*@e3ft.com) http://www.e3ft.com (Consulting Home Page) http://www.dtashley.com (Personal Home Page) http://gpl.e3ft.com (GPL Publications and Projects) 22 3265
David T. Ashley wrote:
I'm writing code which will compile on multiple Windows and multiple *nix
platforms. Some will have 64-bit integers, I believe.
What is my best option to define platform-independent types such as UINT32
or UINT64? I'm not sure how to sort out the various platforms and integer
sizes, and some of it may even vary based on compiler options.
Probably a good place to start would be <stdint.hon one of the 64 bit
capable systems. I think you should use the standard types, rather than
redefining them in caps.
--
Ian Collins.
"Ian Collins" <ia******@hotma il.comwrote in message
news:52******** *****@mid.indiv idual.net...
David T. Ashley wrote:
>I'm writing code which will compile on multiple Windows and multiple *nix platforms. Some will have 64-bit integers, I believe.
What is my best option to define platform-independent types such as UINT32 or UINT64? I'm not sure how to sort out the various platforms and integer sizes, and some of it may even vary based on compiler options.
Probably a good place to start would be <stdint.hon one of the 64 bit
capable systems. I think you should use the standard types, rather than
redefining them in caps.
Thanks for that info. I looked up this file (<stdint.h>) on my Linux box,
and it is just what I was looking for.
However, I also have Microsoft Visual C++. I couldn't find <stdint.hin
the include directory, so just to be sure I wasn't missing something, I
searched Microsoft's site by "stdint.h" and got no matches.
I think the Microsoft tool chain doesn't have such a file. It isn't clear
what to do, because even Windows will run on some 64-bit platforms.
Suggestions?
Dave.
--
David T. Ashley (dt*@e3ft.com) http://www.e3ft.com (Consulting Home Page) http://www.dtashley.com (Personal Home Page) http://gpl.e3ft.com (GPL Publications and Projects)
David T. Ashley a écrit :
"Ian Collins" <ia******@hotma il.comwrote in message
news:52******** *****@mid.indiv idual.net...
>>David T. Ashley wrote:
>>>I'm writing code which will compile on multiple Windows and multiple *nix platforms. Some will have 64-bit integers, I believe.
What is my best option to define platform-independent types such as UINT32 or UINT64? I'm not sure how to sort out the various platforms and integer sizes, and some of it may even vary based on compiler options. Probably a good place to start would be <stdint.hon one of the 64 bit capable systems. I think you should use the standard types, rather than redefining them in caps.
Thanks for that info. I looked up this file (<stdint.h>) on my Linux box,
and it is just what I was looking for.
However, I also have Microsoft Visual C++. I couldn't find <stdint.hin
the include directory, so just to be sure I wasn't missing something, I
searched Microsoft's site by "stdint.h" and got no matches.
I think the Microsoft tool chain doesn't have such a file. It isn't clear
what to do, because even Windows will run on some 64-bit platforms.
Suggestions?
Dave.
Yes. Just copy your linux stdint.h to your Microsoft installation...
NOT very difficult. stdint.h is standard C. Microsoft dpesn't always
comply with it but this is easy to follow.
Of course you should remember that in 64 bit microsoft environment,
long is 32 bits and under 64 bit linux it is 64 bits. The file would
need at most a small editing change.
David T. Ashley <dt*@e3ft.comwr ote:
I'm writing code which will compile on multiple Windows and multiple *nix
platforms. Some will have 64-bit integers, I believe.
There are standard types defined in stdint.h, although the header is
available only in C99: uint32/64_t and uint_least32/64_t
--
Ioan - Ciprian Tandau
tandau _at_ freeshell _dot_ org (hope it's not too late)
(... and that it still works...)
jacob navia wrote:
David T. Ashley a écrit :
>"Ian Collins" <ia******@hotma il.comwrote in message news:52******* ******@mid.indi vidual.net...
>>David T. Ashley wrote:
I'm writing code which will compile on multiple Windows and multiple *nix platforms. Some will have 64-bit integers, I believe.
What is my best option to define platform-independent types such as UINT32 or UINT64? I'm not sure how to sort out the various platforms and integer sizes, and some of it may even vary based on compiler options.
Probably a good place to start would be <stdint.hon one of the 64 bit capable systems. I think you should use the standard types, rather than redefining them in caps.
Thanks for that info. I looked up this file (<stdint.h>) on my Linux box, and it is just what I was looking for.
However, I also have Microsoft Visual C++. I couldn't find <stdint.h> in the include directory, so just to be sure I wasn't missing something, I searched Microsoft's site by "stdint.h" and got no matches.
I think the Microsoft tool chain doesn't have such a file. It isn't clear what to do, because even Windows will run on some 64-bit platforms.
Yes. Just copy your linux stdint.h to your Microsoft installation...
NOT very difficult. stdint.h is standard C. Microsoft dpesn't always
comply with it but this is easy to follow.
Of course you should remember that in 64 bit microsoft environment,
long is 32 bits and under 64 bit linux it is 64 bits. The file would
need at most a small editing change.
Although not standardised, _LLP64 (windows) and _LP64 (just about
everyone else) macros can and often are used to define the memory model
used on 64 bit platforms.
--
Ian Collins.
David T. Ashley wrote:
I looked up this file (<stdint.h>) on my Linux
box, and it is just what I was looking for.
However, I also have Microsoft Visual C++. I couldn't find <stdint.hin
the include directory, so just to be sure I wasn't missing something, I
searched Microsoft's site by "stdint.h" and got no matches.
Take a look at Boost[1]. While it's mainly a C++ library, it also has a
compatibility module for platforms lacking explicitly sized integers. If
it doesn't already work for C, you will probably be able to easily make it
work.
One thing though, which wasn't brought up yet: it is best to avoid such
types. Depending on the context, it might be necessary though.
Uli
[1] www.boost.org
Ulrich Eckhardt wrote:
David T. Ashley wrote:
>>I looked up this file (<stdint.h>) on my Linux box, and it is just what I was looking for.
However, I also have Microsoft Visual C++. I couldn't find <stdint.hin the include directory, so just to be sure I wasn't missing something, I searched Microsoft's site by "stdint.h" and got no matches.
Take a look at Boost[1]. While it's mainly a C++ library, it also has a
compatibility module for platforms lacking explicitly sized integers. If
it doesn't already work for C, you will probably be able to easily make it
work.
One thing though, which wasn't brought up yet: it is best to avoid such
types. Depending on the context, it might be necessary though.
Why should they be avoided?
--
Ian Collins.
"David T. Ashley" wrote:
"Ian Collins" <ia******@hotma il.comwrote:
>David T. Ashley wrote:
>>I'm writing code which will compile on multiple Windows and multiple *nix platforms. Some will have 64-bit integers, I believe.
What is my best option to define platform-independent types such as UINT32 or UINT64? I'm not sure how to sort out the various platforms and integer sizes, and some of it may even vary based on compiler options.
Probably a good place to start would be <stdint.hon one of the 64 bit capable systems. I think you should use the standard types, rather than redefining them in caps.
Thanks for that info. I looked up this file (<stdint.h>) on my
Linux box, and it is just what I was looking for.
However, I also have Microsoft Visual C++. I couldn't find
<stdint.hin the include directory, so just to be sure I wasn't
missing something, I searched Microsoft's site by "stdint.h" and
got no matches.
I think the Microsoft tool chain doesn't have such a file. It
isn't clear what to do, because even Windows will run on some
64-bit platforms.
It doesn't exist under C90, only under C99. However limits.h
exists under both, so you could make your decisions based on the
values in that.
Most of the world has at least partially implemented C99, but
Microsoft is following its usual practice of undermining
standards. Just don't use any Microsoft software.
--
Chuck F (cbfalconer at maineline dot net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home .att.net>
On Sat, 27 Jan 2007 21:10:28 +0100, in comp.lang.c , jacob navia
<ja***@jacob.re mcomp.frwrote:
>David T. Ashley a écrit :
>However, I also have Microsoft Visual C++. I couldn't find <stdint.hin the include directory, so just to be sure I wasn't missing something, I searched Microsoft's site by "stdint.h" and got no matches. Just copy your linux stdint.h to your Microsoft installation...
This may or may not achieve anything, depending on how stdint.h
defines the types. You may also end up copying several other headers.
Some of these may contain architecture-specific details which simply
aren't portable, and you'll either end up with incorrect definitions,
or definitions which surprise you.
Generally headers are _not_ portable between implementations .
>Of course you should remember that in 64 bit microsoft environment, long is 32 bits and under 64 bit linux it is 64 bits. The file would need at most a small editing change.
In my view, that sorta defeats the point. If you know the widths, then
you could just define the whole lot yourself in a private header with
a bunch of #ifs
--
Mark McIntyre
"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it."
--Brian Kernighan This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Chris Uwins |
last post by:
Hi there, i know theres a number of ways I can achieve this but want
to know the best, (but still quite simple).
Up until a year ago I never used Access but have designed a few
databases for work. I am working on Access 2000.
I have basic SQL/VB skills - and am pretty accomplished at putting the
databases together.
Anyway...I've...
|
by: Fr?d?ric Ledain |
last post by:
Hi.
I have to design new API, which some of them have to return a string.
I have mixed feelings about the various strategies I can choose :
1. API(char *s, long *size)
=> the client gives a string pointer and its size; If the server has
to return a longer string, it fails, and the client calls back with a
longer string.
|
by: bobwansink |
last post by:
Hi, I'm relatively new to programming and I would like to create a C++
multi user program. It's for a project for school. This means I will
have to write a paper about the theory too. Does anyone know a good
place to start looking for some theory on the subject of multi user
applications?
I know only bits and pieces, like about...
|
by: Nate |
last post by:
I am in a slight predicament trying to determine the most efficient and
effective way to connect/disconnect from a database within a business object
(c# dll). I'm also keeping in mind the concept of connecting late and
disconnecting early.
Background:
- multi-tier application (code-behind uses properties and methods of the
business...
|
by: maciek |
last post by:
Hi,
I was wondering if anyone could suggest me a book/article/tutorial on
Exception Handling in multi tier Windows Apps. What are the best
practices/ways to implement EH in multi tier enviroment. I read some MS
Best Practices articles on MSDN. It helped a little, but considering
how unexperienced programmer I am, I think I'd need a good...
| |
by: Joe |
last post by:
Is any one charting packing considered to be the "best"? We've used ChartFX
but wasn't too happy about the way data had to be populated along with some
other issues which slip my mind right now and Dundas has bugs and doesn't do
a good enough job displaying axis labels and is very slow to paint large
numbers of series and data points.
We're...
|
by: CptDondo |
last post by:
I have a small, embedded app that uses a webserver to serve up pages
showing status, etc.
Right now all the pages are hard-coded in English. We need to provide
multi-lingual support.
All of the pages are PHP generated. Ideally, I'd like for the PHP
backend to serve up the language based a) the user's locale, and if that
is not set, its...
|
by: MrQuan |
last post by:
G'day all,
I have a requirement to communicate between two or more PCs over the
Internet, however I have no idea how to go about this.
I'm not talking about a chat programme as such, I want to have an
application running 24/7 on a 'base PC' connected to the internet that
can send out data (like a monitoring application). It's not...
|
by: Jeff |
last post by:
I need to read about 100 lines of a csv file into memory.
Each line contains 6 fields.
What is the best way to store this into memory and then read it back.
Is a array of a multi- dimsion array the way to do this.
If so I can read the data into an array using an arraylist for each line
and the fields in a string array but cannot see...
|
by: trullock |
last post by:
Hi,
Can anyone suggest the best way to go about the following...
I'm tracking clicks (mouse down x,y coordinates) on a web page by
using some javascript to create an XHR which sends the coordinates to
a recording service, such as:
/Record.ashx?X=123&Y=456
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it. ...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...
| |