I am porting a large 3D graphics engine from windoze to linux
with the eclipse environment, and have a few C syntax problems
that are over my head.  At the moment I am just compiling the
code to make a 32-bit executable, but I assume 64-bit will yield
similar results.

-----

1:  From an original software package I wrote long ago in
another language, I could declare the value of an f64 AKA
"double" precision floating point constant with:

  $$PI = 0d400921FB54442D18

where the "0d" prefix says "this is a double precision value
input in hexadecimal".  I have about 200 of these, because I was
able to compute bit-accurate values for many fundamental math
constants, and found that assigning ascii-decimal values to the
constant often led to 2~5 bit errors (in the ascii->double code).

That's very nice, but I assume C simply lacks such a nice feature.
So, my question is - what alternatives can you come up with?

The crappy "solution" in the windoze version of my 3D engine
is the following:

const s64 MATH_bit_PI = 0x400921FB54442D18;
const f64 MATH_PI = (*(f64*)&MATH_bit_PI);

Though this is truly revolting, it works on visual studio.
Yes, I have typedefs that define s64 and f64 from the long
conventional type names.

-----

2:  From a linux C header file that I created a few years
ago --- that I am fairly sure used to compile properly --- the
following generate warnings and errors:

typedef union vec004_64 {
   f64   af64[4];
   struct {
      f64   x, y, z, w;
   };
   struct {
      f64   m00, m01;
      f64   m10, m11;
   };
} __attribute__ ((aligned(16)));  // warning displayed here
//
// warning: "useless storage class specifier in empty declaration".
// The above happens on every similar declaration in the file.
//
// Then, down further, i get ***errors*** on every line like this:
//
typedef   vec004_64    f64vec4;      // error displayed on this line
typedef   vec004_64    f64mat2x2;   // error displayed on this line
//
// "expected '=',  ',',  ';', 'asm' or '__attribute__' before f64vec4
//
I am confused.  I remember not being familiar with the
__attribute__ syntax when I found it years ago --- but
at least it compiled and worked back then.

-----

3:  More code that used to compile/work (and does on windoze):

const u08  MATH_AXIS_SHIFT_1  = 0x04;
const u08  MATH_AXIS_SHIFT_2  = 0x08;
const u08  MATH_AXIS_X = 0x01;
const u08  MATH_AXIS_Y = 0x02;
const u08  MATH_AXIS_Z = 0x04;
const u08  MATH_AXIS_A = 0x08;
//
// the above lines compile okay, but the following lines
// generate errors (these are 7 of about 40 lines)
//
const u16 MATH_AXIS_0X   = (MATH_AXIS_X << MATH_AXIS_SHIFT_1);
const u16 MATH_AXIS_0Y   = (MATH_AXIS_Y << MATH_AXIS_SHIFT_1);
const u16 MATH_AXIS_0Z   = (MATH_AXIS_Z << MATH_AXIS_SHIFT_1);
const u16 MATH_AXIS_00X  = (MATH_AXIS_X << MATH_AXIS_SHIFT_2);
const u16 MATH_AXIS_XY   = (MATH_AXIS_X | (MATH_AXIS_Y <<
MATH_AXIS_SHIFT_1));
const u16 MATH_AXIS_XYZ = (MATH_AXIS_X | (MATH_AXIS_Y << 
MATH_AXIS_SHIFT_1)
| (MATH_AXIS_Z << MATH_AXIS_SHIFT_2));
//
// errors say: "initializer element is not constant".  I disagree!!!
//
// the "u08" is just a typedef for "unsigned char/byte"
// the "u16" is just a typedef for "unsigned short"

-----

I'll stop here for now.  Some other errors will vanish when
these are fixed.

I will appreciate whatever help you can give.  Thanks.


Reply via email to