SGI: Development

trying to use round() with CC -c99 ??

Hi,

I am trying to figure out how to use the round() function from CC with a -c99 option

any help would be appreciated.

I am sure that I have got this backwards but when I try to force is I get a bunch of __restrict errors.

When I add <internal/sgimacros.h> nothing much changes

I am sure that the fix to this is probably pretty simple but I can't quite hit the right button

??

Cheers
The SGI MIPSpro compilers support C99 mode compilation only in C, not C++

http://www.sgi.com/products/software/irix/tools/c.html
http://www.sgi.com/products/software/ir ... s/c++.html

Try to include <stdint.h> from C++ code -- it won't work.
Now this is a deep dark secret, so everybody keep it quiet :)
It turns out that when reset, the WD33C93 defaults to a SCSI ID of 0, and it was simpler to leave it that way... -- Dave Olson, in comp.sys.sgi

Currently in commercial service: Image :Onyx2: (2x) :O3x02L:
In the museum : almost every MIPS/IRIX system.
Wanted : GM1 board for Professional Series GT graphics (030-0076-003, 030-0076-004)
hmm,

thanks for your input

that is interesting. So if I write a c program that uses round()

when I compile with c99, or any other option it still get

identifier "round" is undefined.

Additionally C++ code using

#include <cstlib>

to use atoi and it fails with undefined.

Tried the option -LANG:libc_in_namespace_std

which is suggested in the file CC/cstdlib

still no dice. is 7.4 broken with this or am I missing options??

something seems strange here?

Cheers
So round() is C99 only, and defined in <internal/math_core.h>, pulled in by <math.h> :

Code: Select all

#if defined(__c99)
#if defined(__c99)
extern double      round(double);
extern float       roundf(float);
extern long double roundl(long double);

#pragma optional   round
#pragma optional   roundf
#pragma optional   roundl
#endif /* __c99 */


Code: Select all

#include <stdio.h>
#include <math.h>

int main(void)
{
double d1, d2 = 3.1415926535897932384626433832795028841971693993751058209;
d1 = round(d2);

printf("round(PI) = %g\n", d1);
return 0;
}


C99 means MIPSpro 7.4:

Code: Select all

janjaap@speedo:~$ cc -version
MIPSpro Compilers: Version 7.4.4m

janjaap@speedo:~$ cc -fullwarn -c foo.c
cc-1196 cc: REMARK File = foo.c, Line = 11
The indicated function is declared implicitly.

d1 = round(d2);
^

janjaap@speedo:~$ cc -c99 -fullwarn -c foo.c

So far so good, right? But round() is resolved by libm.so regardless, so you might as well declare it external as long as you know you'll be running a reasonably recent IRIX 6.5.x (probably 6.5.18+):

Code: Select all

#ifdef __cplusplus
extern "C" double round(double);
#endif

... and now it compiles and links in C++ as well :)

Alternatively, this snippet should do the same (round x to the nearest integer, but round halfway cases away from zero):

Code: Select all

#include <math.h>
double round_c99(double x)
{
return (x >= 0.0) ? floor(x + 0.5) : ceil(x - 0.5);
}


That should even work on IRIX 5.3 :)
Now this is a deep dark secret, so everybody keep it quiet :)
It turns out that when reset, the WD33C93 defaults to a SCSI ID of 0, and it was simpler to leave it that way... -- Dave Olson, in comp.sys.sgi

Currently in commercial service: Image :Onyx2: (2x) :O3x02L:
In the museum : almost every MIPS/IRIX system.
Wanted : GM1 board for Professional Series GT graphics (030-0076-003, 030-0076-004)