Review your favorite Linux distribution.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
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.


  Search this Thread
Old 11-15-2005, 02:28 PM   #1
Registered: Mar 2004
Location: Austin TX, USA
Distribution: Ubuntu 11.10, Fedora 16
Posts: 547

Rep: Reputation: 30
Issues with multiple data types (C/C++)

Okay here's the deal. In our application, I implement various different libraries, each which like to use their own datatypes. (SDL, OpenGL, and OpenAL are the big three). In addition to that, our application defines its own types, which are nothing more than #define wrappers around the SDL types (we didn't like the naming scheme of the SDL types). So my question here is how do we make all these types friendly with each other?

For example, I want to assign a float to a ALfloat (OpenAL's float) and vice-versa. Do I need to do explicit static_cast calls for each type conversion to eliminate warnings, or is there another trick that we could use with the C preprocessor? (Because there would be A LOT of casting that needs to be done otherwise!).

Also are there any issues we should worry about with word size? All of the standard integer types we use in our app are suffixed with 8, 16, or 32 to define the bit-size, but if I want to assign a Alint (OpenAL's integer) to a uint8, int16 (signed), or uint32, couldn't that potentially be a provlem? Especially considering that this application needs to be cross-platform across 32 and 64 bit architectures, from Linux to MacOS X to (yes, sadly) Windows.

I'm just curious about these issues and how serious they might be. So far everything works across all three systems though. Thanks in advance.
Old 11-15-2005, 04:14 PM   #2
Registered: Oct 2005
Posts: 970

Rep: Reputation: Disabled
I've never used openAL as well i've read its not the finished item and i question wether you need to use it as SDL has sound capabilties. As for opengl/openAl datatypes, I use gl and never ever use GLint Glfloat etc etc i just dont see the point; if you look at the source you should just see:
typedef float GLfloat;
typedef int GLint;
therefore they are just aliases for built in types
Old 11-16-2005, 08:37 PM   #3
LQ Newbie
Registered: Apr 2002
Posts: 6

Rep: Reputation: 0
the problem is just that int on machine A might not be the same as on machine B
there exist 16Bit ints, but I dont't know if any non-freak machine uses them. I have a similar problem ( writing code, that runs evrywhere, talks with evry one by udp, even the apple machines which tend to use the wrong byteorder, as we know ( well as wrong as the side of the street, the British folks use to drive, it's all relative ) ) so made up my mind to use apache APR, and the apr_int32_t etc.
But what about new data types which use 64 bit ? Is there any C/C++ standard yet for those long longs and extra doubles? or does the 64 in Athlon64 just stand for the bigger adress space?


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
How to pass data to a console program with multiple inputs? juanbobo Programming 3 08-18-2005 06:39 PM
Multiple Hardware Issues w/ Dell rjkfsm Linux - Laptop and Netbook 0 05-31-2005 09:17 AM
multiple hardware issues, need ideas! lukebeales Linux - Hardware 1 07-07-2004 06:14 AM
Mozilla issues The document contains no data BarryM45 Linux - General 3 04-05-2004 04:37 AM
mysql and complex data types... gluon Programming 2 10-29-2001 12:50 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:09 AM.

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