ANSI vers non-ANSI "C" question!

ANSI vers non-ANSI "C" question!

Post by Saravanan Arunachal » Sun, 19 May 1996 04:00:00



I am trying to compile a C program with function calls on a HP-UNIX.
I used std ANSI-C features while doing the function call. But while
compiling, it gave an error saying that this format is used in ANSI alone
and not applicable on this machine.

Can somebody please tell me what I need to do to compile and run this
on HP-UNIX? Should I change the format in the function call and if so,
how do I do it, or while compiling can I use a flag to indicate to
use the non-ANSI implementation?

I hope my question was clear, and would appreciate if somebody would
shed some light on this..

Thanks a bunch!!

--- Code follows:

main()
{
        float rad, circ;
        float calculate(float rad);
        circ = calculate(rad);

Quote:}

float calculate(float rad)
{
        float c;
        c = 2 * rad;
        return(c);
        }

---

ps: I have left out the trivia part and just quoted the necessary lines!!

 
 
 

ANSI vers non-ANSI "C" question!

Post by Shaun Flisakows » Mon, 20 May 1996 04:00:00




>I am trying to compile a C program with function calls on a HP-UNIX.
>I used std ANSI-C features while doing the function call. But while
>compiling, it gave an error saying that this format is used in ANSI alone
>and not applicable on this machine.

>Can somebody please tell me what I need to do to compile and run this
>on HP-UNIX? Should I change the format in the function call and if so,
>how do I do it, or while compiling can I use a flag to indicate to
>use the non-ANSI implementation?

  If you are attempting to use the compiler 'cc' that came with
  your machine, you're out of luck unless you bought the developer's
  version. In that case, you should obtain 'gcc', or modify the code.
  To modify the code, you would need to remove the prototypes for
  functions, and change the declarations to the "old style".

  From:
    float calculate(float rad) {

  To:
    float calculate(rad) float rad; {

  If you have the developer's version, use cc with the flags,
  -Aa -DHPUX_SOURCE to get an Ansi/Posix compliant compilation.

Quote:>I hope my question was clear, and would appreciate if somebody would
>shed some light on this..

  This post is off-topic for comp.programming, please read the FAQ for
  a group before posting.  Followups redirected.

--

    http://www.laserpoint.com/    - Shareware Games for Windows & Macs
   "In your heart you know its flat."
                           -Flat Earth Society

 
 
 

ANSI vers non-ANSI "C" question!

Post by Bob Phillip » Mon, 20 May 1996 04:00:00


I believe that you are having the the same problem I had a few months
ago.  In my case it was string initialization that was flagged.

HP 9000 hardware that is shipped with HP-UX 9.04 or greater includes a C
compiler that is not ANSI compliant.  The ANSI compliant compiler is a
seperate product you must purchase from HP.

There are work arounds, but I found it easier just to get the other
compiler.

Hope this helps.

Bob.

 
 
 

ANSI vers non-ANSI "C" question!

Post by krol » Mon, 20 May 1996 04:00:00



> I am trying to compile a C program with function calls on a HP-UNIX.
> I used std ANSI-C features while doing the function call. But while
> compiling, it gave an error saying that this format is used in ANSI alone
> and not applicable on this machine.

> Can somebody please tell me what I need to do to compile and run this
> on HP-UNIX? Should I change the format in the function call and if so,
> how do I do it, or while compiling can I use a flag to indicate to
> use the non-ANSI implementation?

> I hope my question was clear, and would appreciate if somebody would
> shed some light on this..

> Thanks a bunch!!

Code deleted.

Under HP-UX 9 you must specify the "-Aa" flag to cc to get it to
compile in ANSI mode.  You didn't specify which version of HP-UX
you were using, but I believe that this is also true on HP-UX 10.

 
 
 

ANSI vers non-ANSI "C" question!

Post by Dave Plon » Tue, 21 May 1996 04:00:00




> > I am trying to compile a C program with function calls on a HP-UNIX.
> > I used std ANSI-C features while doing the function call. But while
> > compiling, it gave an error saying that this format is used in ANSI alone
> > and not applicable on this machine.

> > Can somebody please tell me what I need to do to compile and run this
> > on HP-UNIX? Should I change the format in the function call and if so,
> > how do I do it, or while compiling can I use a flag to indicate to
> > use the non-ANSI implementation?

[...]

Quote:> Under HP-UX 9 you must specify the "-Aa" flag to cc to get it to
> compile in ANSI mode.  You didn't specify which version of HP-UX
> you were using, but I believe that this is also true on HP-UX 10.

Under HP-UX (and many other systems), I prefer to use "c89" rather than
"cc", to get the ANSI behavior.

Under HP-UX, c89 used to be the equivalent of "cc -Aa".  Under newer
versions it seems to be the equivalent of "cc -Aa -D_POSIX_SOURCE".

I beleive c89 is the POSIX-suggested method to invoke the C compiler, and
since POSIX requires ANSI-C behavior, you should always get ANSI behavior
if you use "c89".  So, c89, if available, is a good choice for any Unix.

Be careful if you upgrade from HP-UX 9.x to 10.x.  We needed to re-install
the optional ANSI C compiler.  It wouldn't do ANSI stuff after the upgrade.
(Ie. Apparently during the upgrade, cc had become the minimalist compiler
that you get for free that's just their to rebuild the kernel.)

Dave

--